Repository navigation
fix: let user keymaps override defaults written with different casing - #794
Open
dinhkarate wants to merge 1 commit into
Open
dinhkarate wants to merge 1 commit into
dinhkarate wants to merge 1 commit into
Conversation
A user keymap such as <c-t> did not replace the default <C-t>: both entries stayed in the keymaps table, so <c-t> = false left the default mapped. Compare keys with nvim_replace_termcodes and drop any default that is the same key as one the user set. Fixes stevearc#692
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.
Fixes #692
A user keymap written with different casing than the default, e.g.
["<c-t>"] = false, did not replace the default["<C-t>"].setup()merges keymaps by raw string, so both entries ended up inconfig.keymapsand the default was still mapped (or the two fought over the key, depending onpairs()order).When merging, the user's key and each default key are now compared after
nvim_replace_termcodes, and a default that is the same key is dropped. Defaults the user set explicitly themselves are left alone, anduse_default_keymaps = falseis unchanged.Tests: new
tests/config_spec.luasets<c-t> = falseand<c-S>to another action, opens oil and checks withmapargthat<C-t>is unmapped,<C-s>runs the user's action and<CR>still has its default. It fails without the change../run_tests.sh: 109 passed, 0 failed (Neovim 0.12.6).luacheck lua testsandstylua --checkare clean.