kevinhwang91 / nvim-hlslens

Hlsearch Lens for Neovim
BSD 3-Clause "New" or "Revised" License
748 stars 10 forks source link

fix(render): fix border is nil #53

Closed mars90226 closed 1 year ago

mars90226 commented 1 year ago

I've encountered lua error and neovim crash due to this bug that assuming window config always have border.

Below is the lua error:

Error executing vim.schedule lua callback: ...acker/start/nvim-hlslens/lua/hlslens/render/floatwin.lua:45: attempt to index local 'border' (a nil value)
stack traceback:
        ...acker/start/nvim-hlslens/lua/hlslens/render/floatwin.lua:45: in function 'borderHasBottomLine'
        ...acker/start/nvim-hlslens/lua/hlslens/render/floatwin.lua:105: in function 'updateFloatWin'
        ...ck/packer/start/nvim-hlslens/lua/hlslens/render/init.lua:235: in function 'setVirt'
        ...ck/packer/start/nvim-hlslens/lua/hlslens/render/init.lua:201: in function 'addLens'
        ...ck/packer/start/nvim-hlslens/lua/hlslens/render/init.lua:333: in function 'doLens'
        ...ck/packer/start/nvim-hlslens/lua/hlslens/render/init.lua:107: in function 'refreshCurrentBuf'
        ...ck/packer/start/nvim-hlslens/lua/hlslens/render/init.lua:413: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

And the neovim core dump backtrace from this bug: bt.txt

kevinhwang91 commented 1 year ago

Thanks, the patch can fix the Lua error. How can you conclude the crash is related to hlslens? I have no idea about the backtrace.

mars90226 commented 1 year ago

The backtrace is generated using the steps in neovim FAQ.

The backtrace indicates that it's doing do_autocmd_cmdlinechanged and since the last step of reproduced steps is "searching in the floating window buffer". I assume that the crash is from the nvim-hlslens's CmdlineChanged autocmd. And after I fix this bug, it won't crash again.

kevinhwang91 commented 1 year ago

Yes, I know you were in do_autocmd_cmdlinechanged before crashing, but I can't reproduce it, maybe hlslens and some plugins produce the crash. BTW, you do a good job.

mars90226 commented 1 year ago

I've also use cmp-cmdline which is plugin that check cmdline input and show possible completion through popup. Maybe the crash only happen when error is thrown while cmp-cmdline is trying to show popup.