folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.24k stars 28 forks source link

bug: Highlight does not update after call `jump({continue=true})` in action #282

Open mrbeardad opened 7 months ago

mrbeardad commented 7 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.4

Operating system/version

Microsoft Windows 11 Home 10.0.22621 N/A Build 22621

Describe the bug

function flash_select_labels()
  require("flash").jump({
    label = {
      format = function(opts)
        return {
          { opts.match.label, opts.match.highlight and opts.hl_group or "FlashLabelChoosed" },
        }
      end,
    },
    action = function(match, state)
      vim.cmd("echo '" .. tostring(match.highlight) .. tostring(match) .. "'")
      match.highlight = not match.highlight
      -- state:_update()
      require("flash").jump({ continue = true })
    end,
  })
end

The highlight of matches and labels doesn't change when I choose them. I'm not sure if this is expected behavior, the highlight update function _update() is called after action, but I've called another jump in action, so the _update() will not be called.

Steps To Reproduce

  1. call the function flash_select_labels above
  2. type, says pattern, to search word
  3. flash show labels after every pattern
  4. type a label char, says a
  5. the highlight of match pattern and label a doesn't change

Expected Behavior

The match pattern should not highlight and label a should changes to highlight group FlashLabelChoosed when I choose the label a.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/flash.nvim", opts = {} },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
github-actions[bot] commented 4 days ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.