Possible fix for issue #4642: use ModeChanged events instead of InsertLeave emulation #4738
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.
ALE is my favourite way of using LSPs and linters, the only thing that might need improvement is #4642. Any time I press Esc and start typing or moving around the document (muscle memory :) ), Vim beeps and Tried switching to NeoVim and Helix, only to return back to Vim+ALE :)
I've done some research/testing during this weekend, and it looks like Vim 9 has some issues (a timeout reset?) if a timer is started from an
InsertEnterEvent
.InsertEnter
is called before switching into Insert mode, somode()
might potentially return "normal" mode if the timer is triggered too early.I was able improve the situation by specifying a shorter timeoutlen, but that doesn't seem like an ideal solution. When Esc or
\<C-[\>
is pressed, Vim waits some time to see if it's an escape code for something else (like an Arrow Up key).ModeChanged
looks like a more reliable way to detect an "exit insert mode" event and is a lot simpler (doesn't need a timer). Also, it can detect some other transitions like\<C-o\>
in insert mode.The
ModeChanged
event is available in:so the current tests are covering both
InsertMode
emulation and the newModeChanged
events.With this PoC, the situation has improved significantly on my machine - no more beeping, and exiting Insert mode is instantaneous.