Skip to content

Commit 8851644

Browse files
committed
fix(suggestion): virtual text flicker
1 parent 5304ea7 commit 8851644

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/copilot/suggestion.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ local function update_preview()
184184
annot = "(" .. copilot._copilot.choice .. "/" .. #copilot._copilot.suggestions .. ")"
185185
end
186186

187+
local cursor_col = vim.fn.col(".")
188+
189+
displayLines[1] = string.sub(
190+
string.sub(suggestion.text, 1, (string.find(suggestion.text, "\n", 1, true) or 0) - 1),
191+
cursor_col
192+
)
193+
187194
local extmark = {
188195
id = copilot.extmark_id,
189196
virt_text_win_col = vim.fn.virtcol(".") - 1,
@@ -205,7 +212,7 @@ local function update_preview()
205212

206213
extmark.hl_mode = "combine"
207214

208-
vim.api.nvim_buf_set_extmark(0, copilot.ns_id, vim.fn.line(".") - 1, vim.fn.col(".") - 1, extmark)
215+
vim.api.nvim_buf_set_extmark(0, copilot.ns_id, vim.fn.line(".") - 1, cursor_col - 1, extmark)
209216

210217
if suggestion.uuid ~= copilot.uuid then
211218
copilot.uuid = suggestion.uuid

0 commit comments

Comments
 (0)