Skip to content

Commit

Permalink
fix: accept replacing first char in line
Browse files Browse the repository at this point in the history
closes #38
  • Loading branch information
Saghen committed Oct 8, 2024
1 parent 98575f0 commit 655d2ee
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lua/blink/cmp/accept/text-edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ function text_edits.guess_text_edit(bufnr, item)
-- Search forward/backward for the start/end of the word
local start_col = current_col
while start_col > 1 do
local char = line:sub(start_col, start_col)
if char:match('[%w_\\-]') == nil then
start_col = start_col + 1
break
end
local char = line:sub(start_col - 1, start_col - 1)
if char:match('[%w_\\-]') == nil then break end
start_col = start_col - 1
end

-- todo: dont search forward since LSPs dont typically do this so it will be inconsistent
-- 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)
Expand Down

0 comments on commit 655d2ee

Please sign in to comment.