hadronized / hop.nvim

Neovim motions on speed!
Other
2.47k stars 137 forks source link

[Bug] Error when trying hop with a floating window open #278

Open akinsho opened 2 years ago

akinsho commented 2 years ago

Hi 👋🏿 ,

Firstly, thanks for your work phaazon, it's much appreciated 💯.

On to the issue, since moving over to hop v2. I've been getting errors when trying to trigger HopChar1MW i.e. a hop job with multiwindow set to true. I've narrowed down this issue to an interaction with nvim-treesitter-context but I think it's probably applicable to any other floating windows, e.g. I believe I've seen this also whilst using nvim-lightbulb.

The error is:

E5108: Error executing lua ...re/nvim/site/pack/packer/opt/hop.nvim/lua/hop/window.lua
:7: Failed to switch to window 1004
stack traceback:
        [C]: in function 'nvim_set_current_win'
        ...re/nvim/site/pack/packer/opt/hop.nvim/lua/hop/window.lua:7: in function 'wi
ndow_context'
        ...re/nvim/site/pack/packer/opt/hop.nvim/lua/hop/window.lua:84: in function 'g
et_window_context'
        ...hare/nvim/site/pack/packer/opt/hop.nvim/lua/hop/init.lua:50: in function 'c
reate_hint_state'
        ...hare/nvim/site/pack/packer/opt/hop.nvim/lua/hop/init.lua:303: in function '
hint_with_callback'
        ...hare/nvim/site/pack/packer/opt/hop.nvim/lua/hop/init.lua:287: in function '
hint_with'
        ...hare/nvim/site/pack/packer/opt/hop.nvim/lua/hop/init.lua:474: in function '
hint_char1'
        [string ":lua"]:1: in main chunk

A minimal init.lua is

vim.cmd("packadd hop.nvim")
vim.cmd("packadd nvim-treesitter-context")

require("hop").setup()
require("treesitter-context").setup()

Then start nvim with v -u ~/minimal.lua --noplugin <path to a large file>

With context enabled, scroll down until the context window appears. With the window in view, press :HopChar1MW and press a character. This will trigger the error.

hadronized commented 2 years ago

That’s an interesting use-case. I’m trying to reproduce and will see how to fix the bug.

hadronized commented 2 years ago

Okay it was easy to reproduce, thanks a lot! I will prioritize that one, it’s pretty bad.

hadronized commented 2 years ago

That first commit fixes a situation that is not exactly the one you described. Can you switch your Hop setup to use branch = fix-multi-window-floats, update, and tell me whether you still reproduce? I’m continuing looking for your situation but I don’t exactly reproduce it.

akinsho commented 2 years ago

Hi, thanks for picking this up. I just tried the latest branch, and it still happens, unfortunately. Scrolled down till there was a context window

image
hadronized commented 2 years ago

Which version of nvim @akinsho are you using? nvim --version should be enough.

akinsho commented 2 years ago
NVIM v0.8.0-dev-2203-gc1652bdcb                                                                                                                                                                 
Build type: Release                                                                                                                                                                             
LuaJIT 2.1.0-beta3                                                                                                                                                                              
Compiled by akin@Akins-MacBook-Pro.local                                                                                                                                                        

Features: +acl +iconv +tui                                                                                                                                                                      
See ":help feature-compile"                                                                                                                                                                     

   system vimrc file: "$VIM/sysinit.vim"                                                                                                                                                        
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-c1652bd_1/share/nvim"                                                                                                                   

Run :checkhealth for more info 
hadronized commented 2 years ago

Thanks!