summaryrefslogtreecommitdiff
path: root/lua/telescope/builtin
diff options
context:
space:
mode:
authorLuyu Huang <luyu_huang@foxmail.com>2023-02-19 20:32:37 +0800
committerGitHub <noreply@github.com>2023-02-19 13:32:37 +0100
commit5d9658c39dca8dd8538dd3eb1ef767374cd9b88f (patch)
tree129f10127c4781df34aef1d296c0220743e0d498 /lua/telescope/builtin
parent443e5a6802849f9e4611a2d91db01b8a37350524 (diff)
fix: apply jump_type only if the definition file is different from the current file (#2324)
Diffstat (limited to 'lua/telescope/builtin')
-rw-r--r--lua/telescope/builtin/__lsp.lua28
-rw-r--r--lua/telescope/builtin/init.lua8
2 files changed, 20 insertions, 16 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
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index c9c0ae3..e74cdf4 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -379,7 +379,7 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jump
---@param opts table: options to pass to the picker
---@field include_declaration boolean: include symbol declaration in the lsp references (default: true)
---@field include_current_line boolean: include current line (default: false)
----@field jump_type string: how to goto reference if there is only one, values: "tab", "split", "vsplit", "never"
+---@field jump_type string: how to goto reference if there is only one and the definition file is different from the current file, values: "tab", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
@@ -401,7 +401,7 @@ builtin.lsp_outgoing_calls = require_on_exported_call("telescope.builtin.__lsp")
--- Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
----@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
+---@field jump_type string: how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
@@ -410,7 +410,7 @@ builtin.lsp_definitions = require_on_exported_call("telescope.builtin.__lsp").de
--- Goto the definition of the type of the word under the cursor, if there's only one,
--- otherwise show all options in Telescope
---@param opts table: options to pass to the picker
----@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
+---@field jump_type string: how to goto definition if there is only one and the definition file is different from the current file, values: "tab", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
@@ -418,7 +418,7 @@ builtin.lsp_type_definitions = require("telescope.builtin.__lsp").type_definitio
--- Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
----@field jump_type string: how to goto implementation if there is only one, values: "tab", "split", "vsplit", "never"
+---@field jump_type string: how to goto implementation if there is only one and the definition file is different from the current file, values: "tab", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)