fix(lsp.reference): only filter the current line of the current filname (#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 <j.trew10@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user