Skip to content

Commit d161597

Browse files
committed
fix: correct strdisplaywidth calculation for signs
1 parent 3d849ce commit d161597

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lua/tiny-inline-diagnostic/diagnostic.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ local function apply_virtual_texts(opts, event)
150150
local filtered_diags = filter_diagnostics(opts, event, diagnostics)
151151
local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - 1
152152
local visible_diags = get_visible_diagnostics(filtered_diags)
153-
local signs_offset = vim.fn.strdisplaywidth(opts.signs.left) + vim.fn.strdisplaywidth(opts.signs.arrow)
154153

155154
-- Clear existing extmarks
156155
extmarks.clear(event.buf)
@@ -189,6 +188,13 @@ local function apply_virtual_texts(opts, event)
189188
local offset = data.offset
190189
local need_to_be_under = data.need_to_be_under
191190
local diagnostic_pos = data.diagnostic_pos
191+
local signs_offset = 0
192+
193+
if need_to_be_under then
194+
signs_offset = vim.fn.strdisplaywidth(opts.signs.left)
195+
else
196+
signs_offset = vim.fn.strdisplaywidth(opts.signs.left) + vim.fn.strdisplaywidth(opts.signs.arrow)
197+
end
192198

193199
extmarks.create_extmarks(
194200
opts,

lua/tiny-inline-diagnostic/virtual_text.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ local function build_first_chunk(opts, chunk_info, message, hl, index_diag, tota
4949

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

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

0 commit comments

Comments
 (0)