mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 17:41:48 +00:00
fix(lsp): multibyte fragment treated as commit char #41019
Problem: commit_chars_str() reads a 0x80-0xBF byte as a 2-byte lead, so "\xA9x" makes "x" a commit character. nvim_get_hl() returns a dict, so `#` on it is 0 whether or not the group exists Solution: use vim.str_utf_end() and drop entries that are not one whole character. use next check dict length.
This commit is contained in:
@@ -1807,7 +1807,8 @@ describe('vim.lsp.completion: integration', function()
|
||||
isIncomplete = false,
|
||||
items = {
|
||||
{
|
||||
commitCharacters = { '.', ',', ';', '(' },
|
||||
-- Only whole characters are kept: '\0' and '\169x' are dropped, '=>' becomes '='.
|
||||
commitCharacters = { '.', ',', ';', '\0', '(', '=>', '\169x' },
|
||||
data = {
|
||||
cacheId = 1,
|
||||
},
|
||||
@@ -1842,6 +1843,18 @@ describe('vim.lsp.completion: integration', function()
|
||||
wait_for_pum()
|
||||
feed('(')
|
||||
eq('f.(', n.api.nvim_get_current_line())
|
||||
|
||||
-- Test that a dropped fragment did not leak: 'x' must not commit, '=' must.
|
||||
n.command('set completeopt=menuone,menu,noinsert')
|
||||
feed('<ESC>Sf.')
|
||||
wait_for_pum()
|
||||
feed('x')
|
||||
eq('f.x', n.api.nvim_get_current_line())
|
||||
|
||||
feed('<ESC>Sf.')
|
||||
wait_for_pum()
|
||||
feed('=')
|
||||
eq('f.bar=', n.api.nvim_get_current_line())
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user