@@ -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 )
259260
260261local 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()
476476end
477477
478478function mod .dismiss ()
479+ reject_current ()
479480 clear ()
480481 update_preview ()
481482end
@@ -521,6 +522,10 @@ local function on_complete_changed()
521522 clear ()
522523end
523524
525+ local function on_vim_leave_pre ()
526+ reject_current ()
527+ end
528+
524529local 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+ })
562573end
563574
564575function mod .setup ()
0 commit comments