Skip to content

Commit 5a08ab9

Browse files
committed
fix: lingering ghost text when suggestions have control chars
fixes #482
1 parent 46a97dc commit 5a08ab9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/copilot/suggestion/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,13 @@ local function update_preview(ctx)
305305
set_ctx_suggestion_text(ctx.choice, suggest_text)
306306
end
307307

308+
local has_control_chars = string.find(suggestion_line1, "%c") ~= nil or #displayLines > 1
309+
308310
local extmark = {
309311
id = copilot.extmark_id,
310312
virt_text = { { suggestion_line1, hl_group.CopilotSuggestion } },
311-
virt_text_pos = "inline",
313+
-- inline does not support system control characters
314+
virt_text_pos = has_control_chars and "eol" or "inline",
312315
}
313316

314317
if #displayLines > 1 then

0 commit comments

Comments
 (0)