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

perf(highlight): skip redraw over folded lines #304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions lua/todo-comments/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ function M.redraw(buf, first, last)
first = math.max(first - Config.options.highlight.multiline_context, 0)
last = math.min(last + Config.options.highlight.multiline_context, vim.api.nvim_buf_line_count(buf))
local state = M.get_state(buf)
for i = first, last do
state.dirty[i] = true
while first <= last do
-- skip over lines that are hidden under a fold
if vim.fn.foldclosed(first) == -1 then
state.dirty[first] = true
else
first = vim.fn.foldclosedend(first)
end
first = first + 1
end
if not M.timer then
M.timer = vim.defer_fn(M.update, Config.options.highlight.throttle)
Expand Down
Loading