-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Pressing Ctrl+C to exit Insert mode sometimes (on removal of autoindent) causes API functions called from an on_lines handler in Lua to error with "Keyboard interrupt" #16416
Comments
@dmitmel the cursor may move after you hit inoremap <C-c> <Esc>`^ |
Mapping |
Mapping |
Instead of remapping `<C-c>` to `<ESC>`, remap to `<C-c>` which also seems to fix the issue (A bit confussing I know). But this way you don't break Telescope prompt where `<C-c>` closes Telescope and `<ESC>` goes into normal mode and just like this there is a bunch of other cases where remapping to `<ESC>` will break some funcionality. reference: <neovim/neovim#16416>
Instead of remapping `<C-c>` to `<ESC>`, remap to `<C-c>` which also seems to fix the issue (A bit confussing I know). But this way you don't break Telescope prompt where `<C-c>` closes Telescope and `<ESC>` goes into normal mode and just like this there is a bunch of other cases where remapping to `<ESC>` will break some funcionality. reference: <neovim/neovim#16416>
Due to the neovim's issue (neovim/neovim#16416), using `vim.fn.expand` sometimes throws Keyboard interrupt error when pressing Ctrl-C (a common alternative to Esc). This works around the above issue by simply getting the buffer number from event argument.
Due to the neovim's issue (neovim/neovim#16416), using `vim.fn.expand` sometimes throws Keyboard interrupt error when pressing Ctrl-C (a common alternative to Esc). This works around the above issue by simply getting the buffer number from event argument.
Neovim version (nvim -v)
0.5.1
Vim (not Nvim) behaves the same?
N/A
Operating system/version
Arch Linux
Terminal name/version
kitty 0.23.1
$TERM environment variable
xterm-kitty
Installation
pacman, official repositories
How to reproduce the issue
test_init.lua
:test_file.js
nvim -u test_lua.lua test_file.js
gg
,o
^C
)Expected behavior
No error is thrown.
Actual behavior
nvim_buf_get_mark
throws the following error:I also want to add that the issue occurs because of autoindentation (that's why I wrote "sometimes" in the title), in particular, that exiting Insert mode from a newly-indented line causes Vim to remove the indentation whitespace.
on_lines
here is most likely invoked right after the editor has switched to Normal mode. The bug also occurs only when calling API functions which usetry_start
andtry_end
in their implementation,nvim_buf_get_mark
was chosen as the simplest example (thus, e.g.,nvim_buf_get_lines
is unaffected).Workaround
For those who encounter this bug and are used to Ctrl+C instead of Esc, this should be a good enough workaround:
The text was updated successfully, but these errors were encountered: