Skip to content

Commit

Permalink
fix: clear last_char on trigger hide
Browse files Browse the repository at this point in the history
closes #228
  • Loading branch information
Saghen committed Nov 5, 2024
1 parent 9771d7c commit 1ce30c9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/blink/cmp/trigger/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,23 @@ function trigger.activate_autocmds()

-- definitely leaving the context
-- TODO: handle leaving snippet mode
vim.api.nvim_create_autocmd({ 'InsertLeave', 'BufLeave' }, { callback = trigger.hide })
vim.api.nvim_create_autocmd({ 'InsertLeave', 'BufLeave' }, {
callback = function()
last_char = ''
trigger.hide()
end,
})

-- manually hide when exiting insert mode with ctrl+c, since it doesn't trigger InsertLeave
local ctrl_c = vim.api.nvim_replace_termcodes('<C-c>', true, true, true)
vim.on_key(function(key)
if key == ctrl_c then
vim.schedule(function()
local mode = vim.api.nvim_get_mode().mode
if mode ~= 'i' then trigger.hide() end
if mode ~= 'i' then
last_char = ''
trigger.hide()
end
end)
end
end)
Expand Down

0 comments on commit 1ce30c9

Please sign in to comment.