kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.16k stars 37 forks source link

Ctrl-C in visual mode terminates some lua execution #202

Closed boltlessengineer closed 3 months ago

boltlessengineer commented 4 months ago

Neovim version (nvim -v | head -n1)

NVIM v0.10.0-dev-2062+ga7550a20e

Operating system/version

Ubuntu 22.04

How to reproduce the issue

When I type CTRL-C on Visual mode, I sometimes see error message below. It doesn’t happen always and I can’t reproduce immediately with same visual selection, so it’s really hard to reproduce. But it happens often enough to notice as a bug. (I’m not sure it’s issue of nvim-ufo side or neovim itself)

I usually use CTRL-C to quit Visual mode and I encountered this issue several times.

Expected behavior

Ctrl-C should not interrupt any internal nvim-ufo code. Vim should go back to Normal mode instead of printing errors.

Actual behavior

Here are errors I’ve encountered when I press Ctrl-C in visual mode.

Error in decoration provider ufo.end:
Error executing lua: Keyboard interrupt
stack traceback:
        [C]: in function 'foldClosed'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:188: in function 'computeFoldedPairs'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:77: in function 'winCall'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:76: in function <...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:66>
Error in decoration provider ufo.end:
Error executing lua: Keyboard interrupt
stack traceback:
        [C]: in function 'foldClosed'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:181: in function 'computeFoldedPairs'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:77: in function 'winCall'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:76: in function <...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:66>

I’ve seen other error messages but they all have Error executing lua: Keyboard interrupt in common.

Edit: add more error message

kevinhwang91 commented 4 months ago

xnoremap <C-c> <Esc> remap should work.

boltlessengineer commented 4 months ago

You are genius. I'll try that for a while and see if problem disappears.

I think this behavior should be prevented by default though.

avegancafe commented 4 months ago

@boltlessengineer @kevinhwang91 for what it's worth, I already have c-c mapped too esc in insert mode and this happens randomly to me too. At the same time it also will make my entire gutter column filled with random vimscript jargon of like v:lua.StatusCol() or something. I'd take a screenshot of it but it bothered me so much that it happened constantly that I removed nvim-ufo from my configuration

LamprosPitsillos commented 3 months ago

https://github.com/Sam-programs/cmdline-hl.nvim/issues/2

boltlessengineer commented 3 months ago

I removed the xnoremap <C-c> <esc> after this issue get closed, but I’m facing similar issue on <C-c> keypress on visual mode.

Error in decoration provider ufo.end:
Error executing lua: Keyboard interrupt
stack traceback:
        [C]: in function 'error'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:141: in function <...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:138>
kevinhwang91 commented 3 months ago

I removed the xnoremap <C-c> <esc> after this issue get closed, but I’m facing similar issue on <C-c> keypress on visual mode.

Error in decoration provider ufo.end:
Error executing lua: Keyboard interrupt
stack traceback:
        [C]: in function 'error'
        ...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:141: in function <...tu/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:138>

https://github.com/kevinhwang91/nvim-ufo/blob/2296dbb8939c4050c222f4eb24889540ef8acd76/lua/ufo/decorator.lua#L140

debug yourself.