Skip to content

Commit

Permalink
fix: search IS blocking, but shouldnt trigger redraw. Fixes #345
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 4, 2024
1 parent 62bfb1d commit b3f08e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lua/noice/message/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ end

function M.check_redraw()
if Util.is_blocking() and M._need_redraw then
-- NOTE: set to false before actually calling redraw to prevent a loop with ui
M._need_redraw = false
Util.redraw()
-- don't do full redraw during search
if not (Util.is_search() and require("noice.ui.cmdline").real_cursor) then
-- NOTE: set to false before actually calling redraw to prevent a loop with ui
M._need_redraw = false
Util.redraw()
end
end
end

Expand Down
13 changes: 8 additions & 5 deletions lua/noice/util/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ function M._diff(a, b)
return false
end

function M.is_search()
local cmdline = require("noice.ui.cmdline")
local c = cmdline.last()
if c and (c.state.firstc == "/" or c.state.firstc == "?") then
return true
end
end

---@param opts? {blocking:boolean, mode:boolean, input:boolean, redraw:boolean}
function M.is_blocking(opts)
opts = vim.tbl_deep_extend("force", {
Expand All @@ -227,11 +235,6 @@ function M.is_blocking(opts)
}, opts or {})
local mode = vim.api.nvim_get_mode()

local c = require("noice.ui.cmdline").last()
if not mode.blocking and c and (c.state.firstc == "/" or c.state.firstc == "?") then
return false
end

local blocking_mode = false
for _, m in ipairs({ "ic", "ix", "c", "no", "r%?", "rm" }) do
if mode.mode:find(m) == 1 then
Expand Down

0 comments on commit b3f08e6

Please sign in to comment.