Skip to content

Commit 4d1b785

Browse files
committed
feat: maintain window on immediate new context while deleting
1 parent 6571c96 commit 4d1b785

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/blink/cmp/trigger.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ function trigger.activate_autocmds()
8585
local cursor_col = vim.api.nvim_win_get_cursor(0)[2]
8686
local char_under_cursor = vim.api.nvim_get_current_line():sub(cursor_col, cursor_col)
8787
local is_on_trigger = vim.tbl_contains(sources.get_trigger_characters(), char_under_cursor)
88+
local is_on_context_char = char_under_cursor:match(trigger.context_regex) ~= nil
8889

8990
if is_within_bounds or (is_on_trigger and trigger.context ~= nil) then
9091
trigger.show()
92+
-- check if we've gone 1 char behind the context and we're still on a context char
93+
elseif is_on_context_char and trigger.context ~= nil and cursor_col == trigger.context.bounds.start_col - 1 then
94+
trigger.context = nil
95+
trigger.show()
9196
elseif config.show_on_insert_on_trigger_character and is_on_trigger and ev.event == 'InsertEnter' then
9297
trigger.show({ trigger_character = char_under_cursor })
9398
else
@@ -182,7 +187,8 @@ function helpers.get_context_bounds(regex)
182187
end_col = end_col + 1
183188
end
184189

185-
return { line_number = cursor_line, start_col = start_col, end_col = end_col }
190+
-- hack: why do we have to math.min here?
191+
return { line_number = cursor_line, start_col = math.min(start_col, end_col), end_col = end_col }
186192
end
187193

188194
return trigger

0 commit comments

Comments
 (0)