diff --git a/lua/fzfx/cfg/_lsp_locations.lua b/lua/fzfx/cfg/_lsp_locations.lua index 45e43c593..ac55c0534 100644 --- a/lua/fzfx/cfg/_lsp_locations.lua +++ b/lua/fzfx/cfg/_lsp_locations.lua @@ -2,6 +2,7 @@ local tbl = require("fzfx.commons.tbl") local path = require("fzfx.commons.path") local fileio = require("fzfx.commons.fileio") local term_color = require("fzfx.commons.color.term") +local str = require("fzfx.commons.str") local switches = require("fzfx.lib.switches") local log = require("fzfx.lib.log") @@ -319,30 +320,32 @@ M._render_lsp_call_hierarchy_line = function(item, ranges) end local lines = {} for i, r in ipairs(ranges) do - local item_line = M._colorize_lsp_range(filelines[r.start.line + 1], r, term_color.red) - log.debug( - string.format( - "|_render_lsp_call_hierarchy_line| %s-range:%s, item_line:%s", - vim.inspect(i), - vim.inspect(r), - vim.inspect(item_line) + if type(filelines) == "table" and #filelines >= r.start.line + 1 then + local item_line = M._colorize_lsp_range(filelines[r.start.line + 1], r, term_color.red) + log.debug( + string.format( + "|_render_lsp_call_hierarchy_line| %s-range:%s, item_line:%s", + vim.inspect(i), + vim.inspect(r), + vim.inspect(item_line) + ) ) - ) - local line = string.format( - "%s:%s:%s:%s", - providers_helper.LSP_FILENAME_COLOR(vim.fn.fnamemodify(filename, ":~:.")), - term_color.green(tostring(r.start.line + 1)), - tostring(r.start.character + 1), - item_line - ) - log.debug( - string.format( - "|_render_lsp_call_hierarchy_line| %s-line:%s", - vim.inspect(i), - vim.inspect(line) + local line = string.format( + "%s:%s:%s:%s", + providers_helper.LSP_FILENAME_COLOR(vim.fn.fnamemodify(filename, ":~:.")), + term_color.green(tostring(r.start.line + 1)), + tostring(r.start.character + 1), + item_line ) - ) - table.insert(lines, line) + log.debug( + string.format( + "|_render_lsp_call_hierarchy_line| %s-line:%s", + vim.inspect(i), + vim.inspect(line) + ) + ) + table.insert(lines, line) + end end return lines end