Skip to content

Commit f4dcebf

Browse files
committed
fix: only undo if not snippet
closes #244
1 parent 8372a6b commit f4dcebf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lua/blink/cmp/accept/init.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ local function accept(item)
1515
local all_text_edits =
1616
vim.deepcopy(resolved_item and resolved_item.additionalTextEdits or item.additionalTextEdits or {})
1717

18-
-- create an undo point
19-
if require('blink.cmp.config').accept.create_undo_point then
20-
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-g>u', true, true, true), 'n', true)
21-
end
22-
2318
item = vim.deepcopy(item)
2419
item.textEdit = text_edits_lib.get_from_item(item)
2520

21+
-- Create an undo point, if it's not a snippet, since the snippet engine should handle undo
22+
if
23+
item.insertTextFormat ~= vim.lsp.protocol.InsertTextFormat.Snippet
24+
and require('blink.cmp.config').accept.create_undo_point
25+
then
26+
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-g>u', true, true, true), 'n', true)
27+
end
28+
2629
-- Add brackets to the text edit if needed
2730
local brackets_status, text_edit_with_brackets, offset = brackets_lib.add_brackets(vim.bo.filetype, item)
2831
item.textEdit = text_edit_with_brackets

0 commit comments

Comments
 (0)