Open drazil100 opened 1 year ago
I noticed this bug today as well. It looks like some things happening on InsertEnter
autocmd cause it, because <c-o>
triggers InsertEnter
. Mainly originating in this part here: https://github.com/hrsh7th/nvim-cmp/blob/2743dd989e9b932e1b4813a4927d7b84272a14e2/lua/cmp/init.lua#L299-L308
My current workaround is something like this, which is not ideal, but fixes the problem:
local ctrl_o_key = function(key)
local ei = vim.opt.eventignore
vim.opt.eventignore = 'InsertEnter'
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<c-o>' .. key, true, true, true))
vim.schedule(function()
vim.opt.eventignore = ei
end)
end
vim.keymap.set('i', '<down>', function() ctrl_o_key('gj') end)
vim.keymap.set('i', '<up>', function() ctrl_o_key('gk') end)
Also just to add, I repro the same issue,
1) entering insert mode at the top of the file
2) hit <cr>
about 15-20 times to add a few lines,
3) hold <up>
key so that it triggers fast
<up>
or <down>
to any cmp actions.Whoops! Seems I had already posted an issue on this earlier and completely forgot. Not sure which issue should be closed but here is the new issue. #2033
FAQ
Announcement
Minimal reproducible full config
Description
When using
<C-o>gj
withcmp.mapping.select_next_item()
or<C-o>gk
withcmp.mapping.select_prev_item()
in insert mode it will generate a bunch of garbage lines at either the top or bottom of the file.Before:
After:
Steps to reproduce
Expected behavior
Nothing happens.
Actual behavior
Garbage lines are being generated.
Additional context
It may be difficult to reproduce, especially with the minimal reproducible full config as it seems to be more likely to trigger the worse neovim is performing. I am on a cheepo $300 Celeron powered laptop and it was a bit of a struggle to get it to happen with the minimal config (only after I opened a stream in the background did it trigger easily). With my regular 1000 line neovim config though it happens at the slightest touch.