Skip to content

Commit cbff2a5

Browse files
committed
fix(jsonfly.lua): resolve function buf_request_all to work with new nvim
syntax and version changes not accounted for. Refactored LSP request handling in jsonfly.lua to combine results from multiple LSP responses and handle empty results more gracefully. Improved code readability and maintainability by restructuring the nested if-else blocks.
1 parent 4d22028 commit cbff2a5

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

Diff for: lua/telescope/_extensions/jsonfly.lua

+27-16
Original file line numberDiff line numberDiff line change
@@ -196,27 +196,38 @@ return require("telescope").register_extension {
196196
if global_config.backend == "lsp" then
197197
local params = vim.lsp.util.make_position_params(xopts.winnr)
198198

199-
vim.lsp.buf_request_all(
200-
current_buf,
201-
"textDocument/documentSymbol",
202-
params,
203-
function(response)
204-
if response == nil or #response == 0 then
205-
run_lua_parser()
206-
return
207-
end
208-
209-
local result = response[1].result
199+
vim.lsp.buf_request_all(
200+
current_buf,
201+
"textDocument/documentSymbol",
202+
params,
203+
function(results)
204+
if results == nil or vim.tbl_isempty(results) then
205+
run_lua_parser()
206+
return
207+
end
210208

211-
local entries = parsers:get_entries_from_lsp_symbols(result)
209+
local combined_result = {}
212210

213-
if allow_cache then
214-
cache:cache_buffer(current_buf, entries)
211+
for _, res in pairs(results) do
212+
if res.result then
213+
vim.list_extend(combined_result, res.result)
215214
end
215+
end
216+
217+
if vim.tbl_isempty(combined_result) then
218+
run_lua_parser()
219+
return
220+
end
221+
222+
local entries = parsers:get_entries_from_lsp_symbols(combined_result)
216223

217-
show_picker(entries, current_buf, xopts)
224+
if allow_cache then
225+
cache:cache_buffer(current_buf, entries)
218226
end
219-
)
227+
228+
show_picker(entries, current_buf, xopts)
229+
end
230+
)
220231
else
221232
run_lua_parser()
222233
end

0 commit comments

Comments
 (0)