Skip to content

Commit e73fe7c

Browse files
committed
fix: invalid column placement when control chars present
1 parent c415c4e commit e73fe7c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lua/copilot/suggestion/init.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,13 @@ local function update_preview(ctx)
312312
virt_text = { { suggestion_line1, hl_group.CopilotSuggestion } },
313313
-- inline does not support system control characters
314314
virt_text_pos = has_control_chars and "eol" or "inline",
315+
hl_mode = "replace",
315316
}
316317

318+
if has_control_chars then
319+
extmark.virt_text_win_col = vim.fn.virtcol(".") - 1
320+
end
321+
317322
if #displayLines > 1 then
318323
extmark.virt_lines = {}
319324
for i = 2, #displayLines do
@@ -327,7 +332,6 @@ local function update_preview(ctx)
327332
extmark.virt_text[3] = { annot, hl_group.CopilotAnnotation }
328333
end
329334

330-
extmark.hl_mode = "replace"
331335
vim.api.nvim_buf_set_extmark(0, copilot.ns_id, vim.fn.line(".") - 1, cursor_col - 1, extmark)
332336

333337
if config.suggestion.suggestion_notification then

0 commit comments

Comments
 (0)