You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once in a while I run into the case where cmp's default <C-n> does not insert the selected item.
In that case, I noticed that require'cmp.view.custom_entries_view'._insert.pending = true and backspace=nostop,
which means that the keys that are nvim_feedkeys()-ed by require'cmp.utils.feedkeys'.call() are not fully executed.
Indeed, it is possible to interrupt the execution of feedkeys()-ed keys with <C-c>.
For example, run following and press <C-c> immediately.
You can see that the keys are not fully processed and thus backspace is not restored from nostop.
While it's very unlikely to happen, it is possible to reproduce this behavior in a more realistic scenario:
type <C-n> then <C-c> almost immediately.
However, I'm not sure if this is what actually happened in my use case, because (I think) I don't use <C-c>.
Steps to reproduce
see above
Expected behavior
Restoration of options and the callback passed to feedkeys.call should be fully executed regardless of user input.
Actual behavior
see above
Additional context
I'm not sure if there is a good solution for this problem.
cmp seems to crucially rely on feedkeys (IIUC, for things like dot repeat?).
nvim doesn't provide option to protect the fed keys from being interrupted.
It seems there is no way to detect if such thing has happened. :h nvim_feedkeys says it sets v:errmsg on error, but this doesn't apply to user interrupt.
The text was updated successfully, but these errors were encountered:
tomtomjhj
changed the title
inconsistent state due when feedkeys-ed keys are interrupted
inconsistent state when feedkeys-ed keys are interrupted
Nov 2, 2024
FAQ
Announcement
Minimal reproducible full config
Description
Once in a while I run into the case where cmp's default
<C-n>
does not insert the selected item.In that case, I noticed that
require'cmp.view.custom_entries_view'._insert.pending = true
andbackspace=nostop
,which means that the keys that are
nvim_feedkeys()
-ed byrequire'cmp.utils.feedkeys'.call()
are not fully executed.Indeed, it is possible to interrupt the execution of
feedkeys()
-ed keys with<C-c>
.For example, run following and press
<C-c>
immediately.You can see that the keys are not fully processed and thus
backspace
is not restored fromnostop
.While it's very unlikely to happen, it is possible to reproduce this behavior in a more realistic scenario:
type
<C-n>
then<C-c>
almost immediately.However, I'm not sure if this is what actually happened in my use case, because (I think) I don't use
<C-c>
.Steps to reproduce
see above
Expected behavior
Restoration of options and the callback passed to
feedkeys.call
should be fully executed regardless of user input.Actual behavior
see above
Additional context
I'm not sure if there is a good solution for this problem.
:h nvim_feedkeys
says it setsv:errmsg
on error, but this doesn't apply to user interrupt.The text was updated successfully, but these errors were encountered: