@@ -175,14 +175,15 @@ function autocomplete.accept()
175
175
end
176
176
177
177
--- @param line number
178
- local function select (line )
178
+ --- @param skip_auto_insert ? boolean
179
+ local function select (line , skip_auto_insert )
179
180
autocomplete .set_has_selected (true )
180
181
vim .api .nvim_win_set_cursor (autocomplete .win :get_win (), { line , 0 })
181
182
182
183
local selected_item = autocomplete .get_selected_item ()
183
184
184
185
-- when auto_insert is enabled, we immediately apply the text edit
185
- if config .windows .autocomplete .selection == ' auto_insert' and selected_item ~= nil then
186
+ if config .windows .autocomplete .selection == ' auto_insert' and selected_item ~= nil and not skip_auto_insert then
186
187
require (' blink.cmp.trigger.completion' ).suppress_events_for_callback (function ()
187
188
if autocomplete .preview_text_edit ~= nil and autocomplete .preview_context_id == autocomplete .context .id then
188
189
text_edits_lib .undo_text_edit (autocomplete .preview_text_edit )
@@ -195,7 +196,8 @@ local function select(line)
195
196
autocomplete .event_targets .on_select (selected_item , autocomplete .context )
196
197
end
197
198
198
- function autocomplete .select_next ()
199
+ --- @param s opts ? { skip_auto_insert ?: boolean }
200
+ function autocomplete .select_next (opts )
199
201
if not autocomplete .win :is_open () then return end
200
202
201
203
local cycle_from_bottom = config .windows .autocomplete .cycle .from_bottom
@@ -213,10 +215,11 @@ function autocomplete.select_next()
213
215
line = line + 1
214
216
end
215
217
216
- select (line )
218
+ select (line , opts and opts . skip_auto_insert )
217
219
end
218
220
219
- function autocomplete .select_prev ()
221
+ --- @param s opts ? { skip_auto_insert ?: boolean }
222
+ function autocomplete .select_prev (opts )
220
223
if not autocomplete .win :is_open () then return end
221
224
222
225
local cycle_from_top = config .windows .autocomplete .cycle .from_top
@@ -230,7 +233,7 @@ function autocomplete.select_prev()
230
233
line = line - 1
231
234
end
232
235
233
- select (line )
236
+ select (line , opts and opts . skip_auto_insert )
234
237
end
235
238
236
239
function autocomplete .listen_on_select (callback ) autocomplete .event_targets .on_select = callback end
0 commit comments