Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(main): check if line is nil when colorizing lsp range #687

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@
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(

Check warning on line 326 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L323-L326

Added lines #L323 - L326 were not covered by tests
"|_render_lsp_call_hierarchy_line| %s-range:%s, item_line:%s",
vim.inspect(i),
vim.inspect(r),
vim.inspect(item_line)

Check warning on line 330 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L328-L330

Added lines #L328 - L330 were not covered by tests
)
)
)
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(

Check warning on line 333 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L333

Added line #L333 was not covered by tests
"%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),

Check warning on line 337 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L335-L337

Added lines #L335 - L337 were not covered by tests
item_line
)
)
table.insert(lines, line)
log.debug(
string.format(

Check warning on line 341 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L340-L341

Added lines #L340 - L341 were not covered by tests
"|_render_lsp_call_hierarchy_line| %s-line:%s",
vim.inspect(i),
vim.inspect(line)

Check warning on line 344 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L343-L344

Added lines #L343 - L344 were not covered by tests
)
)
table.insert(lines, line)

Check warning on line 347 in lua/fzfx/cfg/_lsp_locations.lua

View check run for this annotation

Codecov / codecov/patch

lua/fzfx/cfg/_lsp_locations.lua#L347

Added line #L347 was not covered by tests
end
end
return lines
end
Expand Down
Loading