fix: preserve typeahead order on multi-key sequences#20
Merged
Conversation
The lazy-keys proxy used `nvim_feedkeys` with the `m` flag which appends to the typeahead buffer. For multi-key sequences like `vib`, the trailing `b` was already queued when the proxy fired on `i`, so appending `i` produced the order `b`, `i` instead of `i`, `b`. Result: pressing `vib` behave like `vb`. Switch to the `i` flag to insert at the front, matching lazy.nvim behavior (see lazy/core/handler/keys.lua:140).
zuqini
approved these changes
May 13, 2026
zuqini
left a comment
Owner
There was a problem hiding this comment.
LGTM, thank you for the contribution!
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.
Fix: lazy keys break multi-key sequences (e.g.
vib)Problem
When a plugin is lazy-loaded by a key like
i(modex/o), pressing a multi-key sequence such asvibdoes not work on the first invocation. It behaves as if onlyvbwas pressed.Repro with
mini.ai:{ "nvim-mini/mini.ai", keys = { { "a", mode = { "x", "o" } }, { "i", mode = { "x", "o" } }, }, config = function() require("mini.ai").setup() end, }Full config example here
Place cursor inside
{ "a", "b", "c" }, pressvib— selection fails.It behaves as if only
vbwas pressed (visual mode, then move back a word).It works on second try because plugin already loaded.
Cause
In
lua/zpack/lazy_trigger/keys.luathe proxy re-feeds the lhs with:The
'm'flag appends to the typeahead. When pressingvib:venters visualifires the proxy;bis already queued in typeaheadi→ final order becomesb,ibruns first (move back word) — observed behavior isvblazy.nvimsolves this with the'i'flag (insert at front) — see lazy/core/handler/keys.lua#L140.Fix
One-character change:
'm'→'i'.Test
Added a brief regression test in
tests/lazy_keys_test.lua.Fails on old code, passes after the fix. All 333 → 334 tests pass.