Skip to content

Commit

Permalink
feat: allow to always render search highlight to prevent flickering w…
Browse files Browse the repository at this point in the history
…hen updating ui
  • Loading branch information
folke committed Jun 8, 2023
1 parent 1005faa commit ff0e25f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion lua/flash/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function M.jump(opts)
local state = State.new({ config = opts })

while true do
vim.cmd.redraw()
local ok, n = pcall(vim.fn.getchar)
if not ok then
break
Expand Down
7 changes: 6 additions & 1 deletion lua/flash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ local defaults = {
-- to search with regular expressions
abort_pattern = "[^a-zA-Z0-9_.()]",
-- limit matches in a certain direction
direction = nil, ---@type "forward" | "backward" | nil
direction = "both", ---@type "forward" | "backward" | "both"
},
ui = {
-- When using flash during search, flash will additionally
-- highlight the matches the same way as the search highlight.
-- This is useful to prevent flickring during search.
-- Especially with plugins like noice.nvim.
always_highlight_search = true,
backdrop = true,
priority = 500,
},
Expand Down
2 changes: 1 addition & 1 deletion lua/flash/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function M.update(state)
for _, match in ipairs(state.results) do
local buf = vim.api.nvim_win_get_buf(match.win)

if not state.is_search() then
if not state.is_search() or state.config.ui.always_highlight_search then
vim.api.nvim_buf_set_extmark(buf, M.ns, match.from[1] - 1, match.from[2], {
end_row = match.to[1] - 1,
end_col = match.to[2] + 1,
Expand Down

0 comments on commit ff0e25f

Please sign in to comment.