which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

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

Open ANGkeith opened this issue 1 year ago • 1 comments

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)

  • Fixes #811

ANGkeith avatar Nov 10 '24 14:11 ANGkeith

This PR is stale because it has been open 30 days with no activity.

github-actions[bot] avatar Dec 17 '24 02:12 github-actions[bot]