Skip to content

Commit 859b4b3

Browse files
committed
feat(suggestion): update rejection handling
1 parent 50b45fe commit 859b4b3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/copilot/suggestion.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ local function update_preview()
250250
vim.api.nvim_buf_set_extmark(0, copilot.ns_id, vim.fn.line(".") - 1, cursor_col - 1, extmark)
251251

252252
if suggestion.uuid ~= copilot.uuid then
253+
reject_current()
253254
copilot.uuid = suggestion.uuid
254255
with_client(function(client)
255256
api.notify_shown(client, { uuid = suggestion.uuid }, function() end)
@@ -259,7 +260,6 @@ end
259260

260261
local function clear()
261262
stop_timer()
262-
reject_current()
263263
cancel_inflight_requests()
264264
update_preview()
265265
reset_state()
@@ -476,6 +476,7 @@ function mod.accept_line()
476476
end
477477

478478
function mod.dismiss()
479+
reject_current()
479480
clear()
480481
update_preview()
481482
end
@@ -521,6 +522,10 @@ local function on_complete_changed()
521522
clear()
522523
end
523524

525+
local function on_vim_leave_pre()
526+
reject_current()
527+
end
528+
524529
local function create_autocmds()
525530
vim.api.nvim_create_augroup(copilot.augroup, { clear = true })
526531

@@ -559,6 +564,12 @@ local function create_autocmds()
559564
callback = on_complete_changed,
560565
desc = "[copilot] (suggestion) complete changed",
561566
})
567+
568+
vim.api.nvim_create_autocmd("VimLeavePre", {
569+
group = copilot.augroup,
570+
callback = on_vim_leave_pre,
571+
desc = "[copilot] (suggestion) vim leave pre",
572+
})
562573
end
563574

564575
function mod.setup()

0 commit comments

Comments
 (0)