Repository navigation
fix(keymaps): Keep existing buffer-local mappings across source popups - #50
Merged
Merged
Conversation
…ves them Source popups looked up the mapping to shadow by comparing lhs strings, so <C-j>, <C-w>h and <leader>os never matched Neovim's normalized form (<C-J>, <C-W>h, the expanded leader) and those buffer-local mappings were lost after the popup closed or lost focus. - Snapshot mappings with maparg() in the source buffer and restore them with mapset(), keeping callback, expr, <SID> and multi-mode mappings. - Take every snapshot before installing any popup key and delete before restoring, so lhs spellings that resolve to the same keys stay intact. - Cover Ctrl, leader, <SID> and Lua callback mappings across close and WinLeave, and leave global mappings global.
Restoring a whole :map snapshot reset visual and operator-pending mappings that the popup never touched, discarding changes made while it was open. Cleanup also re-resolved <leader> at close time, so changing mapleader removed an unrelated mapping and leaked the popup's own. - Restore snapshots in normal mode only. - Remember the resolved lhs of each installed mapping and delete by it. - Cover both cases, including closing while another buffer is current.
mhiro2
force-pushed
the
fix/source-popup-keymap-restore
branch
from
October 3, 2026 00:09
6ff1bf9 to
38c8638
Compare
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.
Summary
<C-j>,<C-w>hor<leader>osthat were written with a different spelling than peekstack's keys.maparg()and restored withmapset(), keeping callbacks,expr,<SID>and script context.mapleaderchange while it is open.Changes
<C-J>,<C-W>h, expanded leader) are found.mapset(), and take all snapshots before installing any popup key so aliases that resolve to the same keys stay intact.<SID>and Lua callback mappings across close and WinLeave, and keep global mappings global.:mapmapping changed during the popup are kept.mapleaderneither removes an unrelated mapping nor leaks the popup's own.