folke / flash.nvim

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

bug: `noice.util.is_blocking` from "noice.nvim' breaks search UI #345

Closed b0ae989c closed 1 month ago

b0ae989c commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.0 LuaJIT 2.1.1716656478

Operating system/version

macOS 14.5

Describe the bug

Since 4e1f9f198226aea5b82a6df75e9913b49796cdda, the new noice.util.is_blocking check breaks search UI when we have flash.nvim and noice.nvim

When we do forward search, matched keywords and labels are highlighted, but the string in the search box is missing the last character.

Steps To Reproduce

  1. Run nvim -u init.lua init.lua
  2. Type /opt

Expected Behavior

Search box contains the string "opt", and all matched strings are highlighted.

Repro

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
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)
local plugins = {
    "folke/tokyonight.nvim",
    {
        "folke/noice.nvim",
        dependencies = "MunifTanjim/nui.nvim",
        opts = {},
    },
    {
        "folke/flash.nvim",
        keys = { "/" },
        opts = {
            modes = {
                search = { enabled = true },
            },
        },
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
folke commented 1 month ago

Fixed in noice. Thank you for reporting!

b0ae989c commented 1 month ago

Thanks! However, the fix https://github.com/folke/noice.nvim/commit/b3f08e6cf0fd30847f299cc94707563920fd2139 seems to introduce a new UI issue. The \t character in front of the fake cursor got highlighted when we enter forward search mode.

As shown in the screenshot below, the \t character turns blue. I think this is related to redrawing strategy in noice.message.router.check_redraw.

To reproduce with the config above:

  1. Run nvim -u init.lua init.lua
  2. Type 11G
  3. Type /

Screenshot 2024-06-04 at 3 14 57 PM

folke commented 1 month ago

I just updated the flash.nvim code to use real cursors on Neovim >= 0.10