VonHeikemen / searchbox.nvim

Start your search from a more comfortable place, say the upper right corner?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cursor doesn't jump for out of focus search matches

txtyash opened this issue · comments

If a cursor is say at the top and the search result is at the bottom(out of
screen's focus) then cursor doesn't jump to the search result until you press
return.

With the neovim's default / the cursor jumps to the search result.

can you tell me which type of search? incsearch works fine for me.

can you tell me which type of search? incsearch works fine for me.

Oh, It works fine but I didn't notice it because there's no highlighting. This
is my mapping:

map("n", "<C-f>", '<cmd>lua require("searchbox").incsearch().match_all({clear_matches = false})<CR>', defo)

It doesn't highlight until I press n to jump to the next result. It also shows
an error when executing the binding:

E5108: Error executing lua [string ":lua"]:1: attempt to index a nil value
stack traceback:
        [string ":lua"]:1: in main chunk

Okay this keybinding works fine(no error):

map("n", "<C-f>", '<cmd>lua require("searchbox").incsearch()<CR>', defo)

BUT no live highlighting of matches until I press return and then n to go to
the next match.

Maybe is a theme issue? If the highlight function fails you would get a long error message.

Try adding this in your config, right before you declare your colorscheme.

autocmd ColorScheme * highlight link SearchBoxMatch Search
autocmd ColorScheme * highlight link SearchBoxMatch Search

That worked!

Tried multiple themes but didn't seem to be a theme issue.

I'm using this command rn:

map("n", "<C-f>", ":SearchBoxIncSearch clear_matches=false<CR>", { noremap = true, silent = true })

but clear_matches doesn't seem to be working. Intended value is false.

The type of search you want is match_all. incsearch ignores clear_matches, because it only highlights the nearest match.

You were right, the cursor did not move when using match_all. This feature was added now in 2169e72.

This should work now.

map("n", "<C-f>", ":SearchBoxMatchAll<CR>", { noremap = true, silent = true })

The type of search you want is match_all. incsearch ignores clear_matches, because it only highlights the nearest match.

You were right, the cursor did not move when using match_all. This feature was added now in 2169e72.

This should work now.

map("n", "<C-f>", ":SearchBoxMatchAll<CR>", { noremap = true, silent = true })

Works like a charm!