mirror of
https://github.com/neovim/neovim.git
synced 2025-11-20 01:01:22 +00:00
fix(lsp): don't overlay insertion-style inline completions (#36477)
* feat(lua): `Range:is_empty()` to check vim.range emptiness * fix(lsp): don't overlay insertion-style inline completions **Problem:** Some servers commonly respond with an empty inline completion range which acts as a position where text should be inserted. However, the inline completion module assumes that all responses with a range are deletions + insertions that thus require an `overlay` display style. This causes an incorrect preview, because the virtual text should have the `inline` display style (to reflect that this is purely an insertion). **Solution:** Only use `overlay` for non-empty replacement ranges.
This commit is contained in:
@@ -83,6 +83,27 @@ describe('vim.lsp.inline_completion', function()
|
||||
},
|
||||
handlers = {
|
||||
['textDocument/inlineCompletion'] = function(_, _, callback)
|
||||
if _G.empty then
|
||||
callback(nil, {
|
||||
items = {
|
||||
{
|
||||
insertText = 'foobar',
|
||||
range = {
|
||||
start = {
|
||||
line = 0,
|
||||
character = 19,
|
||||
},
|
||||
['end'] = {
|
||||
line = 0,
|
||||
character = 19,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
callback(nil, {
|
||||
items = {
|
||||
{
|
||||
@@ -198,6 +219,19 @@ describe('vim.lsp.inline_completion', function()
|
||||
screen:expect({ grid = grid_applied_candidates })
|
||||
end)
|
||||
|
||||
it('correctly displays with absent/empty range', function()
|
||||
exec_lua(function()
|
||||
_G.empty = true
|
||||
end)
|
||||
feed('I')
|
||||
screen:expect([[
|
||||
function fibonacci({1:foobar}) |
|
||||
^ |
|
||||
{1:~ }|*11
|
||||
{3:-- INSERT --} |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('accepts on_accept callback', function()
|
||||
feed('i')
|
||||
screen:expect({ grid = grid_with_candidates })
|
||||
|
||||
Reference in New Issue
Block a user