From 655d2ee2673950451a491294fd3ce7e17cfb0a24 Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Tue, 8 Oct 2024 15:55:38 -0400 Subject: [PATCH] fix: accept replacing first char in line closes #38 --- lua/blink/cmp/accept/text-edits.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/blink/cmp/accept/text-edits.lua b/lua/blink/cmp/accept/text-edits.lua index 68753762..667f9491 100644 --- a/lua/blink/cmp/accept/text-edits.lua +++ b/lua/blink/cmp/accept/text-edits.lua @@ -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)