Handle suffixes of cancelled keymaps in insert mode #8486
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.
Fixes #2612. There are several potential design choices here, but I tried to strike a good balance between supporting this case, preserving existing behavior, and exhibiting reasonable behavior.
In particular, #2612 (comment) points out that, in the general case, it should be possible to cancel a pending key sequence by hitting any non-matched key, with no further effect. However, that was already violated by the existing behavior in insert mode, which would execute each key of a pending key sequence individually when cancelled. It seems like a bug that this never considered key sequences of length greater than one in any suffix of the sequence.
That property seems like it would be good to uphold where it doesn't interfere with expected insert typing, so as a compromise, I've made key sequences just cancel entirely if the first key isn't a regular character. This means that if a key sequence starts with a special character (e.g. an F key), then we assume the user wouldn't type it accidentally by trying to insert text (like is common with escape sequences like
fd
,jk
, etc.).