Skip to content

Commit 3c6a1d2

Browse files
committed
fix(suggestion): handle chars inserted within debounce timeout
1 parent 858bbfa commit 3c6a1d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lua/copilot/suggestion.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ function mod.accept(modifier)
478478
clear_preview()
479479

480480
local range, newText = suggestion.range, suggestion.text
481+
local cursor = vim.api.nvim_win_get_cursor(0)
482+
local line, character = cursor[1] - 1, cursor[2]
483+
if range["end"].line == line and range["end"].character < character then
484+
range["end"].character = character
485+
end
481486

482487
-- Hack for 'autoindent', makes the indent persist. Check `:help 'autoindent'`.
483488
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", true, false, true), "n", false)

0 commit comments

Comments
 (0)