fix(builtin.lsp): extra No Name buffer opening with jump_type (#2990)

(cherry picked from commit 5730b950d9)
This commit is contained in:
James Trew
2024-03-18 09:41:56 -04:00
committed by Simon Hauser
parent 332465c706
commit 6d61c905ee
+17 -5
View File
@@ -165,15 +165,27 @@ local function list_or_jump(action, title, opts)
if #flattened_results == 0 then
return
elseif #flattened_results == 1 and opts.jump_type ~= "never" then
local uri = params.textDocument.uri
if uri ~= flattened_results[1].uri and uri ~= flattened_results[1].targetUri then
local current_uri = params.textDocument.uri
local target_uri = flattened_results[1].uri or flattened_results[1].targetUri
if current_uri ~= target_uri then
local cmd
local file_path = vim.uri_to_fname(target_uri)
if opts.jump_type == "tab" then
vim.cmd "tabedit"
cmd = "tabedit"
elseif opts.jump_type == "split" then
vim.cmd "new"
cmd = "new"
elseif opts.jump_type == "vsplit" then
vim.cmd "vnew"
cmd = "vnew"
elseif opts.jump_type == "tab drop" then
cmd = "tab drop"
else
utils.notify(
"list_or_jump",
{ msg = string.format("Invalid jump_type for %s picker", title), level = "ERROR" }
)
return
end
vim.cmd(string.format("%s %s", cmd, file_path))
end
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
else