]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1247: fragile setup to get (preferred) keys from key_name_entry v9.1.1247
authorYee Cheng Chin <ychin.git@gmail.com>
Thu, 27 Mar 2025 16:43:41 +0000 (17:43 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 27 Mar 2025 16:51:03 +0000 (17:51 +0100)
commit7d8e7df55190e8e4e5a66f443e4440b52edf2fdb
tree4af0862590be2a3e27d18b12f28b29db385f7693
parent4f9b1243e3ef60b9efb64a4e789c55be3cdc7a25
patch 9.1.1247: fragile setup to get (preferred) keys from key_name_entry

Problem:  fragile setup to get (preferred) keys from key_name_entry
          (after v9.1.1179)
Solution: refactor the code further, fix a bug with "pref_name" key
          entry introduced in v9.1.1180 (Yee Cheng Chin)

The optimization introduced for using bsearch() with key_name_entry
in #16788 was fragile as it required synchronizing a non-obvious index
(e.g. IDX_KEYNAME_SWU) with the array that could be accidentally changed
by any one adding a key to it. Furthermore, the "pref_name" that was
introduced in that change was unnecessary, and in fact introduced a bug,
as we don't always want to use the canonical name.

The bug is triggered when the user triggers auto-complete using a
keycode, such as `:set <Scroll<Tab>`. The bug would end up showing two
copies of `<ScrollWheelUp>` because both entries end up using the
canonical name.

In this change, remove `pref_name`, and simply use a boolean to track
whether an entry is an alt name or not and modify logic to respect that.

Add test to make sure auto-complete works with alt names

closes: #16987

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/misc2.c
src/testdir/test_options.vim
src/version.c