folke / flash.nvim

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

bug: Incorrect Positioning of Hidden Label When Toggling Flash During Search #273

Closed tummetott closed 4 months ago

tummetott commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.4 Build type: Release LuaJIT 2.1.1696795921

Operating system/version

MacOs 13.4.1

Describe the bug

When the current search label is disabled, the hidden label is positioned incorrectly if the search was initially turned off by default but later activated using a keymap during the search.

Steps To Reproduce

  1. nvim --clean -u repro.lua repro.lua
  2. Close lazy: q
  3. Seach something and enable flash search: /local<c-s>

    --> The current label is hidde but at the wrong positon (the next position after the search, not the current)

Expected Behavior

The hidden label is the current one (which i can jump with <CR>)

By the way: The hidden label is correctly positioned when flash is enabled before starting the search. However, it appears at the wrong position when toggling on flash during the search.

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 = {
            label = {
                current = false,
            },
            modes = {
                search = {
                    enabled = false,
                }
            }
        },
        keys = {
            {
                '<c-s>',
                function() require('flash').toggle() end,
                mode = { 'c' },
                desc = 'Toggle Flash Search',
            },
        }
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
github-actions[bot] commented 4 months 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.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 7 days with no activity.