Skip to content

Commit

Permalink
fix(main): check if line is nil when colorizing lsp range (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
stong1994 authored Apr 26, 2024
1 parent 352906f commit ba8d3ef
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions lua/fzfx/cfg/_lsp_locations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba8d3ef

Please sign in to comment.