Skip to content

Commit ea61b1d

Browse files
committed
fix: only affect initial show for show_on_keyword and show_on_trigger_character
Related to #402
1 parent e1d3e9d commit ea61b1d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lua/blink/cmp/completion/trigger.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ function trigger.activate()
5757
if trigger.context ~= nil then trigger.show({ send_upstream = false }) end
5858

5959
-- character forces a trigger according to the sources, create a fresh context
60-
elseif trigger.is_trigger_character(char) and config.show_on_trigger_character then
60+
elseif trigger.is_trigger_character(char) and (config.show_on_trigger_character or trigger.context ~= nil) then
6161
trigger.context = nil
6262
trigger.show({ trigger_character = char })
6363

64-
-- character is part of the current context OR in an existing context
65-
elseif char:match(keyword_config.regex) ~= nil and config.show_on_keyword then
64+
-- character is part of a keyword
65+
elseif char:match(keyword_config.regex) ~= nil and (config.show_on_keyword or trigger.context ~= nil) then
6666
trigger.show()
6767

6868
-- nothing matches so hide
@@ -82,7 +82,7 @@ function trigger.activate()
8282
local char_under_cursor = vim.api.nvim_get_current_line():sub(cursor_col, cursor_col)
8383
local is_on_trigger_for_show = trigger.is_trigger_character(char_under_cursor)
8484
local is_on_trigger_for_show_on_insert = trigger.is_trigger_character(char_under_cursor, true)
85-
local is_on_context_char = char_under_cursor:match(keyword_config.regex) ~= nil
85+
local is_on_keyword_char = char_under_cursor:match(keyword_config.regex) ~= nil
8686

8787
local insert_enter_on_trigger_character = config.show_on_trigger_character
8888
and config.show_on_insert_on_trigger_character
@@ -100,7 +100,7 @@ function trigger.activate()
100100
trigger.show({ trigger_character = char_under_cursor })
101101

102102
-- show if we currently have a context, and we've moved outside of it's bounds by 1 char
103-
elseif is_on_context_char and trigger.context ~= nil and cursor_col == trigger.context.bounds.start_col - 1 then
103+
elseif is_on_keyword_char and trigger.context ~= nil and cursor_col == trigger.context.bounds.start_col - 1 then
104104
trigger.context = nil
105105
trigger.show()
106106

0 commit comments

Comments
 (0)