Skip to content

Commit ac70821

Browse files
committed
fix(suggestion): fix race condition between accept and cycling
1 parent 19c1c94 commit ac70821

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/copilot/suggestion.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,13 @@ local function get_suggestions_cycling_callback(state, err, data)
303303
return
304304
end
305305

306+
if not state.suggestions then
307+
return
308+
end
309+
306310
local seen = {}
307311

308-
for _, suggestion in ipairs(state.suggestions or {}) do
312+
for _, suggestion in ipairs(state.suggestions) do
309313
seen[suggestion.text] = true
310314
end
311315

@@ -401,7 +405,9 @@ function mod.accept(modifier)
401405
return
402406
end
403407

408+
cancel_inflight_requests()
404409
reset_state()
410+
405411
with_client(function(client)
406412
if modifier then
407413
-- do not notify_accepted for partial accept.

0 commit comments

Comments
 (0)