fix: a suggestion never outlives insert mode - #13
Merged
Merged
Conversation
Two ways a suggestion ended up painted in Normal mode, where <Tab>, <M-Right> and <C-]> — all insert mappings — can't reach it: - The reply race. The request leaves on the debounce, <Esc> lands a few hundred ms later, and the reply was painted into Normal mode anyway: the buffer tick hadn't changed, so the stale-response check let it through. render_result now drops any reply that lands outside insert/replace mode (logged as "DROP … outside insert"); the next InsertEnter asks afresh. - <C-c>. Unmapped, it is an interrupt, and :h i_CTRL-C says it never fires InsertLeave — so the leave handler never ran. The handler now hangs off ModeChanged, which sees every exit: for an interrupt Neovim defers it past got_int and fires it from normal_check, still before any other key is read. While there, how you leave now decides whether it counts. <Esc>, <C-c> and <C-\><C-n> file the rejection as before. <C-o> is a detour: the display clears (the command may edit the buffer under it), nothing is filed, and the return trip re-offers the edit. Before, <C-o>zz twice would hard-reject a suggestion you never said no to. test/modes_spec.lua drives Neovim's real main loop with nvim_input — the blocked-feedkeys harness in flow_spec never reaches normal-mode events — and covers all three. Against the pre-fix code it fails 6 of 15 assertions. Closes #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #10.
TL;DR
A suggestion could sit in Normal mode with a
⟪<Tab> accept · <Esc> dismiss⟫label that neither key could reach — both are insert mappings. Suggestions now live strictly in insert mode.Two leak paths
<Esc>render_resultdrops any reply landing outside insert/replace (DROP … outside insertin:NeocursorLog)<C-c>to leave insert<C-c>is an interrupt;:h i_CTRL-C— never firesInsertLeaveModeChanged, which Neovim fires for every exit (deferred pastgot_int, before any other key)Leaving insert: what counts
Before,
<C-o>zztwice would hard-reject a suggestion you never said no to.Tests
New
test/modes_spec.luadrives Neovim's real main loop withnvim_input— the blocked-feedkeysharness inflow_specnever reaches normal-mode events, and<C-c>is sent as the real interrupt.flow_spec (both hint modes), hints_spec, docs_links and the headless demo harness all still pass.
Docs
README "Saying no" gets the insert-only rule and the
<C-o>exception; troubleshooting covers<Tab>in Normal mode and:NeocursorSuggestfrom the cmdline.