folke / flash.nvim

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

bug: flash crashes when running inside command line window #344

Closed brunobmello25 closed 4 months ago

brunobmello25 commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.5

Operating system/version

MacOS 14.5

Describe the bug

Error description: When trying to use flash inside the command line window, this error happens:

E5108: Error executing lua: ...o/.local/share/nvim/lazy/flash.nvim/lua/flash/prompt.lua:51: E11: Invalid in command-line window; <CR> executes, CTRL-C quits
stack traceback:
        [C]: in function 'nvim_win_close'
        ...o/.local/share/nvim/lazy/flash.nvim/lua/flash/prompt.lua:51: in function 'hide'
        ...lo/.local/share/nvim/lazy/flash.nvim/lua/flash/state.lua:417: in function 'loop'
        ....local/share/nvim/lazy/flash.nvim/lua/flash/commands.lua:9: in function 'jump'

Steps To Reproduce

Expected Behavior

should move cursor to expected position, and not error.

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 = {} },
  {
    "folke/flash.nvim",
    event = "VeryLazy",
    opts = {
      modes = {
        search = {
          enabled = false
        },
      },
    },
    -- stylua: ignore
    keys = {
      { "s",     mode = { "n", "x", "o" }, function() require("flash").jump() end,              desc = "Flash" },
      { "S",     mode = { "n", "x", "o" }, function() require("flash").treesitter() end,        desc = "Flash Treesitter" },
      { "r",     mode = "o",               function() require("flash").remote() end,            desc = "Remote Flash" },
      { "R",     mode = { "o", "x" },      function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
      { "<c-s>", mode = { "c" },           function() require("flash").toggle() end,            desc = "Toggle Flash Search" },
    },
  }
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 4 months ago

Yes, the cmdline window is special. You can't do anything like that there