summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/provider/python.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-08-16 13:20:36 +0800
committerGitHub <noreply@github.com>2025-08-16 13:20:36 +0800
commit013af17ed906179ce1cddf29cfaab078a47f8ea0 (patch)
tree2ce25f34fbb8bf3706b38229b0172fa79bf0c296 /runtime/lua/vim/provider/python.lua
parentc12701d4e1404a67fef6da01a8a9d7e2d48d78d6 (diff)
vim-patch:9.1.1623: Buffer menu does not handle unicode names correctly (#35353)
Problem: Buffer menu does not handle unicode names correctly (after v9.1.1622) Solution: Fix the BMHash() function (Yee Cheng Chin) The Buffers menu uses a BMHash() function to generate a sortable number to be used for the menu index. It used a naive (and incorrect) way of encoding multiple ASCII values into a single integer, but assumes each character to be only in the ASCII 32-96 range. This means if we use non-ASCII file names (e.g. Unicode values like CJK or emojis) we get integer underflow and overflow, causing the menu index to wrap around. Vim's GUI implementations internally use a signed 32-bit integer for the `gui_mch_add_menu_item()` function and so we need to make sure the menu index is in the (0, 2^31-1) range. To do this, if the file name starts with a non-ASCII value, we just use the first character's value and set the high bit so it sorts after the other ASCII ones. Otherwise, we just take the first 5 characters, and use 5 bit for each character to encode a 30-bit number that can be sorted. This means Unicode file names won't be sorted beyond the first character. This is likely going to be fine as there are lots of ways to query buffers. related: vim/vim#17403 closes: vim/vim#17928 https://github.com/vim/vim/commit/8f9de4991e84dfdc9bcc9dad0eaa2b3544ef963e Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Diffstat (limited to 'runtime/lua/vim/provider/python.lua')
0 files changed, 0 insertions, 0 deletions