diff options
| author | Luyu Huang <luyu_huang@foxmail.com> | 2023-02-19 20:32:37 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-19 13:32:37 +0100 |
| commit | 5d9658c39dca8dd8538dd3eb1ef767374cd9b88f (patch) | |
| tree | 129f10127c4781df34aef1d296c0220743e0d498 /lua/telescope/builtin/__lsp.lua | |
| parent | 443e5a6802849f9e4611a2d91db01b8a37350524 (diff) | |
fix: apply jump_type only if the definition file is different from the current file (#2324)
Diffstat (limited to 'lua/telescope/builtin/__lsp.lua')
| -rw-r--r-- | lua/telescope/builtin/__lsp.lua | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lua/telescope/builtin/__lsp.lua b/lua/telescope/builtin/__lsp.lua index c23f25c..96b7cfa 100644 --- a/lua/telescope/builtin/__lsp.lua +++ b/lua/telescope/builtin/__lsp.lua @@ -40,12 +40,14 @@ lsp.references = function(opts) end if #locations == 1 and opts.jump_type ~= "never" then - if opts.jump_type == "tab" then - vim.cmd "tabedit" - elseif opts.jump_type == "split" then - vim.cmd "new" - elseif opts.jump_type == "vsplit" then - vim.cmd "vnew" + if filepath ~= locations[1].filename then + if opts.jump_type == "tab" then + vim.cmd "tabedit" + elseif opts.jump_type == "split" then + vim.cmd "new" + elseif opts.jump_type == "vsplit" then + vim.cmd "vnew" + end end -- jump to location local location = locations[1] @@ -184,12 +186,14 @@ local function list_or_jump(action, title, opts) if #flattened_results == 0 then return elseif #flattened_results == 1 and opts.jump_type ~= "never" then - if opts.jump_type == "tab" then - vim.cmd "tabedit" - elseif opts.jump_type == "split" then - vim.cmd "new" - elseif opts.jump_type == "vsplit" then - vim.cmd "vnew" + if params.textDocument.uri ~= flattened_results[1].uri then + if opts.jump_type == "tab" then + vim.cmd "tabedit" + elseif opts.jump_type == "split" then + vim.cmd "new" + elseif opts.jump_type == "vsplit" then + vim.cmd "vnew" + end end vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding) else |
