folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.06k stars 161 forks source link

bug: which key(<C-w>c) may get stuck when remapping certain keys (recursion) #715

Closed imzhongqi closed 1 month ago

imzhongqi commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-422+g3c803483a

Operating system/version

MacOS 14.5

Describe the bug

When I remap c, when I press c repeatedly, nvim doesn't work (seems to be going into recurrence), here is the smallest recurrence repository address: https://github.com/imzhongqi/which-key-recurring,and here is a log file:https://github.com/imzhongqi/which-key-bug-repo, i just use lazyvim default starter repo and i add <C-w>c keymap.

Steps To Reproduce

  1. Repeat execution c in open neotree
  2. The second time it goes into recursion and nvim doesn't work

Expected Behavior

Everything works.

Health

==============================================================================
which-key: require("which-key.health").check()

- OK Most of these checks are for informational purposes only.
  WARNINGS should be treated as a warning, and don't necessarily indicate a problem with your config.
  Please |DON't| report these warnings as an issue.

Checking your config ~
- OK |mini.icons| is installed
- OK |nvim-web-devicons| is installed

Checking for issues with your mappings ~
- OK No issues reported

checking for overlapping keymaps ~
- WARNING In mode `n`, <g> overlaps with <g[>, <gc>, <gcc>, <gco>, <gcO>, <g]>, <g%>, <grr>, <grn>, <gra>, <gx>:
  - <g>: goto
  - <g[>: Move to left "around"
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
  - <gco>: Add Comment Below
  - <gcO>: Add Comment Above
  - <g]>: Move to right "around"
  - <g%>: Cycle backwards through results
  - <grr>: vim.lsp.buf.references()
  - <grn>: vim.lsp.buf.rename()
  - <gra>: vim.lsp.buf.code_action()
  - <gx>: Open file with system app
- WARNING In mode `x`, <i> overlaps with <in>, <il>:
  - <i>: inside
  - <in>: next
  - <il>: last
- WARNING In mode `x`, <a> overlaps with <al>, <an>, <a%>:
  - <a>: around
  - <al>: last
  - <an>: next
- WARNING In mode `o`, <a> overlaps with <an>, <al>:
  - <a>: around
  - <an>: next
  - <al>: last
- WARNING In mode `o`, <i> overlaps with <in>, <il>:
  - <i>: inside
  - <in>: next
  - <il>: last
- WARNING In mode `n`, <gc> overlaps with <gcc>, <gco>, <gcO>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
  - <gco>: Add Comment Below
  - <gcO>: Add Comment Above
- OK Overlapping keymaps are only reported for informational purposes.
  This doesn't necessarily mean there is a problem with your config.

Checking for duplicate mappings ~
- OK No duplicate mappings found

Log

https://github.com/imzhongqi/which-key-bug-repo/blob/main/wk.log

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/which-key.nvim", opts = {
} },
    -- add any other plugins here
  },
})
folke commented 1 month ago

Can't reproduce this using that repo. Are you certain that you are using the latest version?

folke commented 1 month ago

If you are, please tell me the exact steps / keys to type to trigger the issue

imzhongqi commented 1 month ago
  1. git clone https://github.com/imzhongqi/which-key-recurring ~/.config/lazyvim
  2. git clone https://github.com/imzhongqi/which-key-bug-repo && cd which-key-bug-repo
  3. export NVIM_APPNAME=lazyvim
  4. open nvim
  5. Open the neotree pane
  6. Open main.go and type <C-w>c(this closes main.go), keymap define here: https://github.com/imzhongqi/which-key-recurring/blob/main/lua/config/keymaps.lua
  7. Repeat step 2 a few times and he stops working.
imzhongqi commented 1 month ago

Can't reproduce this using that repo. Are you certain that you are using the latest version?

I am sure that the latest version of this repository was submitted by me at github.com/imzhongqi/which-key-recurring

folke commented 1 month ago

Can reproduce. Will check