mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(lsp): set tagstack on jump via goto methods
Follow up to https://github.com/neovim/neovim/pull/30877 Fixes https://github.com/neovim/neovim/issues/30926
This commit is contained in:
committed by
Mathias Fußenegger
parent
5c44c02405
commit
3c51058d76
@ -54,6 +54,9 @@ local function get_locations(method, opts)
|
||||
return
|
||||
end
|
||||
local win = api.nvim_get_current_win()
|
||||
local from = vim.fn.getpos('.')
|
||||
from[1] = bufnr
|
||||
local tagname = vim.fn.expand('<cword>')
|
||||
local remaining = #clients
|
||||
|
||||
---@type vim.quickfix.entry[]
|
||||
@ -89,6 +92,13 @@ local function get_locations(method, opts)
|
||||
if #all_items == 1 then
|
||||
local item = all_items[1]
|
||||
local b = item.bufnr or vim.fn.bufadd(item.filename)
|
||||
|
||||
-- Save position in jumplist
|
||||
vim.cmd("normal! m'")
|
||||
-- Push a new item into tagstack
|
||||
local tagstack = { { tagname = tagname, from = from } }
|
||||
vim.fn.settagstack(vim.fn.win_getid(win), { items = tagstack }, 't')
|
||||
|
||||
vim.bo[b].buflisted = true
|
||||
local w = opts.reuse_win and vim.fn.win_findbuf(b)[1] or win
|
||||
api.nvim_win_set_buf(w, b)
|
||||
|
@ -5107,10 +5107,15 @@ describe('LSP', function()
|
||||
return {
|
||||
cursor = vim.api.nvim_win_get_cursor(win),
|
||||
messages = server.messages,
|
||||
tagstack = vim.fn.gettagstack(win),
|
||||
}
|
||||
end)
|
||||
eq('textDocument/definition', result.messages[3].method)
|
||||
eq({ 1, 0 }, result.cursor)
|
||||
eq(1, #result.tagstack.items)
|
||||
eq('x', result.tagstack.items[1].tagname)
|
||||
eq(3, result.tagstack.items[1].from[2])
|
||||
eq(7, result.tagstack.items[1].from[3])
|
||||
end)
|
||||
it('merges results from multiple servers', function()
|
||||
exec_lua(create_server_definition)
|
||||
|
Reference in New Issue
Block a user