Skip to content
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

fix(state): recursion in hydra mode when mapping does not exist #884

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ANGkeith
Copy link

@ANGkeith ANGkeith commented Nov 10, 2024

Description

# minimal.lua
vim.g.mapleader = " "

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
  },
})

local wk = require("which-key")

wk.add({
  {
    "<leader>mq",
    function()
      print("i am mq")
    end,
  },
  {
    "<leader>mw",
    function()
      print("i am mw")
    end,
  },
  {
    "<leader>mj",
    "j",
  },
  {
    "<leader>m",
    function()
      vim.notify("hail hydra")
      require("which-key").show({
        keys = "<leader>m",
        loop = true, -- this will keep the popup open until you hit <esc>
      })
    end,
  },
})

Before this pr, given the above config,

there's currently two problem:

  1. issuing the key <leader>mjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...., we will falsly get the recusion warning
  2. issuing the key <leader>mh, we end up in a recursion

Related Issue(s)

lua/which-key/state.lua Outdated Show resolved Hide resolved
@ANGkeith ANGkeith marked this pull request as ready for review November 10, 2024 14:31
@@ -294,7 +305,8 @@ function M.start(opts)
M.recursion = 0
end)

if M.recursion > 50 then
recursion_threshold = M.hydra_mode and 200 or 50
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increasing the threshold for hydra mode to fix the problem # 1 as described in the pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: recursion when settings up hydra?
1 participant