Skip to content

Commit

Permalink
fix(utils): handle inlay hint label correctly
Browse files Browse the repository at this point in the history
Previously, the inlay hint label handling did not account for cases where
the label was not an array. This caused errors in calculating the offset
for some LSP servers such as rust-analyzer
  • Loading branch information
tris203 committed Aug 5, 2024
1 parent 6772d3a commit c0f8571
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/precognition/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ end
---@return integer
---@return integer
function M.calc_ws_offset(hint, tab_width, current_line)
local label = (hint.inlay_hint.label[1] and hint.inlay_hint.label[1].value) or hint.inlay_hint.label or ""
-- + 1 here because of trailing padding
local length = #hint.inlay_hint.label[1].value + 1
local length = #label + 1
local start = hint.inlay_hint.position.character
local prefix = vim.fn.strcharpart(current_line, 0, start)
local expanded = string.gsub(prefix, "\t", string.rep(" ", tab_width))
Expand Down

0 comments on commit c0f8571

Please sign in to comment.