Skip to content

Commit

Permalink
feat: don't search forward when guessing text edit
Browse files Browse the repository at this point in the history
closes Saghen#58
This behavior wasn't obvious and wasn't consistent since it only applied
to LSPs which didn't pass textEdits. This may be re-introduced behind a
flag in the future
  • Loading branch information
Saghen authored and lopi-py committed Oct 10, 2024
1 parent 740a92a commit e29c3b7
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions lua/blink/cmp/accept/text-edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,11 @@ function text_edits.guess_text_edit(bufnr, item)
start_col = start_col - 1
end

-- todo: optionally dont search forward since LSPs dont typically do this with textEdits
-- so this will lead to inconsistent behavior
-- OR add support on textEdits
local end_col = current_col
while end_col < #line do
local char = line:sub(end_col + 1, end_col + 1)
if char:match('[%w_\\-]') == nil then break end
end_col = end_col + 1
end

-- convert to 0-index
return {
range = {
start = { line = current_line - 1, character = start_col - 1 },
['end'] = { line = current_line - 1, character = end_col },
['end'] = { line = current_line - 1, character = current_col },
},
newText = word,
}
Expand Down

0 comments on commit e29c3b7

Please sign in to comment.