Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent state when feedkeys-ed keys are interrupted #2077

Open
2 tasks done
tomtomjhj opened this issue Nov 2, 2024 · 0 comments
Open
2 tasks done

inconsistent state when feedkeys-ed keys are interrupted #2077

tomtomjhj opened this issue Nov 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tomtomjhj
Copy link
Contributor

tomtomjhj commented Nov 2, 2024

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

nvim --clean --cmd 'set runtimepath^=/path/to/nvim-cmp'

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 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.

:lua require'cmp.utils.feedkeys'.call(string.rep('asdf', 12345), 'int')

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.
@tomtomjhj tomtomjhj added the bug Something isn't working label Nov 2, 2024
@tomtomjhj tomtomjhj changed the title inconsistent state due when feedkeys-ed keys are interrupted inconsistent state when feedkeys-ed keys are interrupted Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant