Skip to content

Commit

Permalink
fix(lsp.reference): only filter the current line of the current filna…
Browse files Browse the repository at this point in the history
…me (#3154)

* fix(lsp.reference): Only filter the current line of the current filname

fix(lsp.reference): Only filter the current line of the current filname when include_current_line=false

* fix(lsp.reference): Only filter the current line of the current filname

* run stylua

---------

Co-authored-by: James Trew <[email protected]>
  • Loading branch information
Lonzoghf and jamestrew committed Jun 8, 2024
1 parent dfa230b commit 3a74349
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lua/telescope/builtin/__lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ local apply_action_handler = function(action, items, opts)
if action == "textDocument/references" and not opts.include_current_line then
local lnum = vim.api.nvim_win_get_cursor(opts.winnr)[1]
items = vim.tbl_filter(function(v)
return not (v.filename and v.lnum == lnum)
return not (v.filename == opts.curr_filepath and v.lnum == lnum)
end, items)
end

Expand All @@ -154,8 +154,8 @@ end
---@param opts table
local function list_or_jump(action, title, params, opts)
opts.reuse_win = vim.F.if_nil(opts.reuse_win, false)
opts.curr_filepath = vim.api.nvim_buf_get_name(opts.bufnr)

local curr_filepath = vim.api.nvim_buf_get_name(opts.bufnr)
vim.lsp.buf_request(opts.bufnr, action, params, function(err, result, ctx, _)
if err then
vim.api.nvim_err_writeln("Error when executing " .. action .. " : " .. err.message)
Expand All @@ -182,7 +182,7 @@ local function list_or_jump(action, title, params, opts)

if #items == 1 and opts.jump_type ~= "never" then
local item = items[1]
if curr_filepath ~= item.filename then
if opts.curr_filepath ~= item.filename then
local cmd
if opts.jump_type == "tab" then
cmd = "tabedit"
Expand Down

0 comments on commit 3a74349

Please sign in to comment.