This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
RFC: allow special case Infinity grouping interval #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a tentative PR for a feature that I think will benefit the vim-mode package (cf. atom/vim-mode#849). A change with
groupingInterval
ofInfinity
will group with any change coming after it (provided that one has non-0groupingInterval
), no matter how long it takes.The rationale: in vim-mode, the command
ciwabc<escape>
will change (c
) the current word (iw
) to the textabc
. An experienced VIM user will expect a single undo both to remove theabc
and to restore the current word as it was, but it's also common that there's a break between the change commandciw
and the typed textabc
because they are cognitively different chunks of typing.With this PR, vim-mode could group the deletion of the current word with the
abc
(provided that was typed fast enough for the default 300ms grouping interval), and experienced VIM users would get the benefit of undoing the semantically related changes together (makes sense in vim-mode), and still using the normal timed grouping of undo for text changes (makes sense in modern text editors).To make sure those
Infinity
-grouped commands don't accidentally get grouped with changes that don't belong in a group, vim-mode can do an empty transaction with 0 grouping interval (as done in atom/vim-mode#849):We can't easily use
groupChangesSinceCheckpoint
because there's no good way of knowing when to trigger it (at least I haven't found one).I can add specs if you like the general idea.