Skip to content

Conversation

@soifou
Copy link
Collaborator

@soifou soifou commented Oct 25, 2025

Completion items didn't include the textEdit field before, so blink.cmp had to guess where to insert them. That guess was sometimes off, e.g., when the character before the cursor is the same as the first character of the expanded snippet, leading to incorrect insertion.

Closes #2159

@saghen
Copy link
Owner

saghen commented Oct 27, 2025

We should include the whole keyword in the text edit range, which you can grab from context.bounds. I haven't tested, but I'd guess that if you manually <C-space> at test|, accepting the snippet would delete only the final t

Completion items didn't include the `textEdit` field before, so
blink.cmp had to guess where to insert them. That guess was sometimes
off, e.g., when the character before the cursor is the same as the first
character of the expanded snippet, leading to incorrect insertion.

Closes #2159
@soifou soifou force-pushed the fix/builtin-snippet branch from 44799df to 3f63ebf Compare October 28, 2025 00:23
@saghen
Copy link
Owner

saghen commented Oct 28, 2025

Thinking about this more, we should set the text edit to the guessed range based on only the label. Otherwise, snippets with label ;foo will only replace the foo on execution.

The issue is https://github.com/saghen/blink.cmp/blob/main/lua/blink/cmp/lib/text_edits.lua#L201 calls into https://github.com/saghen/blink.cmp/blob/main/lua/blink/cmp/fuzzy/rust/lib.rs#L166, which gets the edit range from all of label, filterText and insertText. The insertText contains the expanded snippet and iirc there were some issues with lazydev.nvim around this (ref). Might have my facts wrong here though, it's been a while...

Maybe we could skip guessing on insertText for snippets generally, but I think I prefer guessing the range specifically for this source and setting the textEdit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inside parenthesis, extra characters/whitespaces before the cursor are delete during completion

3 participants