Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improving perf of force redraw #232

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/grug-far/actions/replace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ local function replace(params)
state.actionMessage = update.message
end
renderResultsHeader(buf, context)
resultsList.throttledForceRedrawBuffer(buf)
resultsList.throttledForceRedrawBuffer(buf, context)
end,
on_finish = on_finish_all,
})
Expand Down
2 changes: 1 addition & 1 deletion lua/grug-far/actions/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ local function search(params)
renderResultsHeader(buf, context)

resultsList.appendResultsChunk(buf, context, data)
resultsList.throttledForceRedrawBuffer(buf)
resultsList.throttledForceRedrawBuffer(buf, context)

if shouldAbortEarly then
if state.abort.search then
Expand Down
2 changes: 1 addition & 1 deletion lua/grug-far/actions/sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ local function sync(params)
end
state.actionMessage = getActionMessage(nil, changesCount, changesTotal)
renderResultsHeader(buf, context)
resultsList.throttledForceRedrawBuffer(buf)
resultsList.throttledForceRedrawBuffer(buf, context)
end,
on_finish = function(status, errorMessage, customActionMessage)
if state.bufClosed then
Expand Down
8 changes: 6 additions & 2 deletions lua/grug-far/render/resultsList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,16 @@ end

--- force redraws buffer. This is order to apear more responsive to the user
--- and quickly give user feedback as results come in / data is updated
--- note that only the "top" range of lines is redrawn, including a bunch of lines
--- after headerRow so that we immediately get error messages to show up
---@param buf integer
function M.forceRedrawBuffer(buf)
---@param context GrugFarContext
function M.forceRedrawBuffer(buf, context)
---@diagnostic disable-next-line
if vim.api.nvim__redraw then
---@diagnostic disable-next-line
vim.api.nvim__redraw({ buf = buf, flush = true })
vim.api.nvim__redraw({ buf = buf, flush = true, range = { 0, context.state.headerRow + 100 } })
-- vim.api.nvim__redraw({ buf = buf, flush = true })
end
end

Expand Down
Loading