Skip to content

Commit

Permalink
fix: correct strdisplaywidth calculation for signs
Browse files Browse the repository at this point in the history
  • Loading branch information
rachartier committed Feb 23, 2025
1 parent 3d849ce commit d161597
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lua/tiny-inline-diagnostic/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ local function apply_virtual_texts(opts, event)
local filtered_diags = filter_diagnostics(opts, event, diagnostics)
local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - 1
local visible_diags = get_visible_diagnostics(filtered_diags)
local signs_offset = vim.fn.strdisplaywidth(opts.signs.left) + vim.fn.strdisplaywidth(opts.signs.arrow)

-- Clear existing extmarks
extmarks.clear(event.buf)
Expand Down Expand Up @@ -189,6 +188,13 @@ local function apply_virtual_texts(opts, event)
local offset = data.offset
local need_to_be_under = data.need_to_be_under
local diagnostic_pos = data.diagnostic_pos
local signs_offset = 0

if need_to_be_under then
signs_offset = vim.fn.strdisplaywidth(opts.signs.left)
else
signs_offset = vim.fn.strdisplaywidth(opts.signs.left) + vim.fn.strdisplaywidth(opts.signs.arrow)
end

extmarks.create_extmarks(
opts,
Expand Down
2 changes: 1 addition & 1 deletion lua/tiny-inline-diagnostic/virtual_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local function build_first_chunk(opts, chunk_info, message, hl, index_diag, tota

if index_diag == 1 then
local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - 1
local chunk_arrow = chunk_utils.get_arrow_from_chunk(opts, cursor_line, chunk_info, hl.diag_hi)
local chunk_arrow = chunk_utils.get_arrow_from_chunk(opts, cursor_line, chunk_info, hl.diag_inv_hi)

if type(chunk_arrow[1]) == "table" then
return { chunk_arrow, chunk_header }
Expand Down

0 comments on commit d161597

Please sign in to comment.