mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
fix(lsp): call show_document with correct args
Closes https://github.com/neovim/neovim/issues/21177
This commit is contained in:
@@ -579,7 +579,10 @@ M['window/showDocument'] = function(_, result, ctx, _)
|
|||||||
range = result.selection,
|
range = result.selection,
|
||||||
}
|
}
|
||||||
|
|
||||||
local success = util.show_document(location, client.offset_encoding, true, result.takeFocus)
|
local success = util.show_document(location, client.offset_encoding, {
|
||||||
|
reuse_win = true,
|
||||||
|
focus = result.takeFocus,
|
||||||
|
})
|
||||||
return { success = success or false }
|
return { success = success or false }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -2689,6 +2689,33 @@ describe('LSP', function()
|
|||||||
eq(10, pos.col)
|
eq(10, pos.col)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('jumps to a Location if focus is true via handler', function()
|
||||||
|
exec_lua(create_server_definition)
|
||||||
|
local result = exec_lua([[
|
||||||
|
local server = _create_server()
|
||||||
|
local client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
|
||||||
|
local result = {
|
||||||
|
uri = 'file:///fake/uri',
|
||||||
|
selection = {
|
||||||
|
start = { line = 0, character = 9 },
|
||||||
|
['end'] = { line = 0, character = 9 }
|
||||||
|
},
|
||||||
|
takeFocus = true,
|
||||||
|
}
|
||||||
|
local ctx = {
|
||||||
|
client_id = client_id,
|
||||||
|
method = 'window/showDocument',
|
||||||
|
}
|
||||||
|
vim.lsp.handlers['window/showDocument'](nil, result, ctx)
|
||||||
|
vim.lsp.stop_client(client_id)
|
||||||
|
return {
|
||||||
|
cursor = vim.api.nvim_win_get_cursor(0)
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
eq(1, result.cursor[1])
|
||||||
|
eq(9, result.cursor[2])
|
||||||
|
end)
|
||||||
|
|
||||||
it('jumps to a Location if focus not set', function()
|
it('jumps to a Location if focus not set', function()
|
||||||
local pos = show_document(location(0, 9, 0, 9), nil, true)
|
local pos = show_document(location(0, 9, 0, 9), nil, true)
|
||||||
eq(1, pos.line)
|
eq(1, pos.line)
|
||||||
|
Reference in New Issue
Block a user