Skip to content

Commit 85922dd

Browse files
authored
refactor: adapt to deprecated jump_to_location (#3344)
1 parent f06e7a8 commit 85922dd

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

lua/telescope/builtin/__files.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ files.treesitter = function(opts)
442442
end
443443

444444
results = utils.filter_symbols(results, opts)
445-
if results == nil then
445+
if vim.tbl_isempty(results) then
446446
-- error message already printed in `utils.filter_symbols`
447447
return
448448
end

lua/telescope/builtin/__lsp.lua

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ end
100100
--- convert `item` type back to something we can pass to `vim.lsp.util.jump_to_location`
101101
--- stopgap for pre-nvim 0.10 - after which we can simply use the `user_data`
102102
--- field on the items in `vim.lsp.util.locations_to_items`
103-
---@param item vim.lsp.util.locations_to_items.ret
103+
---@param item vim.quickfix.entry
104104
---@param offset_encoding string|nil utf-8|utf-16|utf-32
105105
---@return lsp.Location
106106
local function item_to_location(item, offset_encoding)
@@ -134,9 +134,9 @@ end
134134
---| "textDocument/implementation"
135135

136136
---@param action telescope.lsp.list_or_jump_action
137-
---@param items vim.lsp.util.locations_to_items.ret[]
137+
---@param items vim.quickfix.entry[]
138138
---@param opts table
139-
---@return vim.lsp.util.locations_to_items.ret[]
139+
---@return vim.quickfix.entry[]
140140
local apply_action_handler = function(action, items, opts)
141141
if action == "textDocument/references" and not opts.include_current_line then
142142
local lnum = vim.api.nvim_win_get_cursor(opts.winnr)[1]
@@ -148,9 +148,9 @@ local apply_action_handler = function(action, items, opts)
148148
return items
149149
end
150150

151-
---@param items vim.lsp.util.locations_to_items.ret[]
151+
---@param items vim.quickfix.entry[]
152152
---@param opts table
153-
---@return vim.lsp.util.locations_to_items.ret[]
153+
---@return vim.quickfix.entry[]
154154
local function filter_file_ignore_patters(items, opts)
155155
local file_ignore_patterns = vim.F.if_nil(opts.file_ignore_patterns, conf.file_ignore_patterns)
156156
file_ignore_patterns = file_ignore_patterns or {}
@@ -242,7 +242,7 @@ local function list_or_jump(action, title, funname, params, opts)
242242
end
243243

244244
local location = item_to_location(item, first_encoding)
245-
vim.lsp.util.jump_to_location(location, first_encoding, opts.reuse_win)
245+
vim.lsp.util.show_document(location, first_encoding, { reuse_win = opts.reuse_win })
246246
else
247247
pickers
248248
.new(opts, {
@@ -263,6 +263,7 @@ end
263263

264264
lsp.references = function(opts)
265265
opts.include_current_line = vim.F.if_nil(opts.include_current_line, false)
266+
---@class lsp.TextDocumentPositionParams
266267
local params = vim.lsp.util.make_position_params(opts.winnr)
267268
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) }
268269
return list_or_jump("textDocument/references", "LSP References", "builtin.lsp_references", params, opts)
@@ -339,7 +340,7 @@ lsp.document_symbols = function(opts)
339340

340341
local locations = vim.lsp.util.symbols_to_items(result or {}, opts.bufnr) or {}
341342
locations = utils.filter_symbols(locations, opts, symbols_sorter)
342-
if locations == nil then
343+
if vim.tbl_isempty(locations) then
343344
-- error message already printed in `utils.filter_symbols`
344345
return
345346
end
@@ -382,7 +383,7 @@ lsp.workspace_symbols = function(opts)
382383

383384
local locations = vim.lsp.util.symbols_to_items(server_result or {}, opts.bufnr) or {}
384385
locations = utils.filter_symbols(locations, opts, symbols_sorter)
385-
if locations == nil then
386+
if vim.tbl_isempty(locations) then
386387
-- error message already printed in `utils.filter_symbols`
387388
return
388389
end
@@ -424,7 +425,7 @@ local function get_workspace_symbols_requester(bufnr, opts)
424425
cancel = vim.lsp.buf_request_all(bufnr, "workspace/symbol", { query = prompt }, tx)
425426

426427
local results = rx() ---@type table<integer, {error: lsp.ResponseError?, result: lsp.WorkspaceSymbol?}>
427-
local locations = {} ---@type vim.lsp.util.locations_to_items.ret[]
428+
local locations = {} ---@type vim.quickfix.entry[]
428429

429430
for _, client_res in pairs(results) do
430431
if client_res.error then

lua/telescope/utils.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ utils.filter_symbols = function(results, opts, post_filter)
121121
msg = "Either opts.symbols or opts.ignore_symbols, can't process opposing options at the same time!",
122122
level = "ERROR",
123123
})
124-
return
124+
return {}
125125
elseif not (has_ignore or has_symbols) then
126126
return results
127127
elseif has_ignore then
@@ -133,7 +133,7 @@ utils.filter_symbols = function(results, opts, post_filter)
133133
msg = "Please pass ignore_symbols as either a string or a list of strings",
134134
level = "ERROR",
135135
})
136-
return
136+
return {}
137137
end
138138

139139
opts.ignore_symbols = vim.tbl_map(string.lower, opts.ignore_symbols)
@@ -149,7 +149,7 @@ utils.filter_symbols = function(results, opts, post_filter)
149149
msg = "Please pass filtering symbols as either a string or a list of strings",
150150
level = "ERROR",
151151
})
152-
return
152+
return {}
153153
end
154154

155155
opts.symbols = vim.tbl_map(string.lower, opts.symbols)

0 commit comments

Comments
 (0)