mirror of
https://github.com/neovim/neovim.git
synced 2026-04-30 11:14:10 +00:00
fix(lsp): clear word when expand multi-lines word (#32393)
Problem: When expanding a completion item that contains a multi-line word, the word is not deleted correctly. Solution: If the word contains a line break, delete the text from Context.cursor to the current cursor position.
This commit is contained in:
@@ -1113,4 +1113,42 @@ describe('vim.lsp.completion: integration', function()
|
||||
end)
|
||||
)
|
||||
end)
|
||||
|
||||
it('#clear multiple-lines word', function()
|
||||
local completion_list = {
|
||||
isIncomplete = false,
|
||||
items = {
|
||||
{
|
||||
label = 'then...end',
|
||||
sortText = '0001',
|
||||
insertText = 'then\n\t$0\nend',
|
||||
kind = 15,
|
||||
insertTextFormat = 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
exec_lua(function()
|
||||
vim.o.completeopt = 'menuone,noselect'
|
||||
end)
|
||||
create_server('dummy', completion_list)
|
||||
feed('Sif true <C-X><C-O>')
|
||||
retry(nil, nil, function()
|
||||
eq(
|
||||
1,
|
||||
exec_lua(function()
|
||||
return vim.fn.pumvisible()
|
||||
end)
|
||||
)
|
||||
end)
|
||||
feed('<C-n><C-y>')
|
||||
eq(
|
||||
{ true, { 'if true then', '\t', 'end' } },
|
||||
exec_lua(function()
|
||||
return {
|
||||
vim.snippet.active({ direction = 1 }),
|
||||
vim.api.nvim_buf_get_lines(0, 0, -1, true),
|
||||
}
|
||||
end)
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user