Skip to content

Commit

Permalink
fix: only affect initial show for show_on_keyword and show_on_trigger…
Browse files Browse the repository at this point in the history
…_character

Related to #402
  • Loading branch information
Saghen committed Nov 29, 2024
1 parent e1d3e9d commit ea61b1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lua/blink/cmp/completion/trigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ function trigger.activate()
if trigger.context ~= nil then trigger.show({ send_upstream = false }) end

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

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

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

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

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

Expand Down

0 comments on commit ea61b1d

Please sign in to comment.