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

bug: performance issues on large files with folds #285

Closed
3 tasks done
mtrajano opened this issue Jul 2, 2024 · 2 comments · May be fixed by #304
Closed
3 tasks done

bug: performance issues on large files with folds #285

mtrajano opened this issue Jul 2, 2024 · 2 comments · May be fixed by #304
Labels
bug Something isn't working stale

Comments

@mtrajano
Copy link

mtrajano commented Jul 2, 2024

Did you check docs and existing issues?

  • I have read all the todo-comments.nvim docs
  • I have searched the existing issues of todo-comments.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

MacOS 13.6.3

Describe the bug

When scrolling on a large file with folds there is a very noticeable lag during scrolling. There's a WinScroll autocommand that fires in order to update the window highlights. This works fine if there are no folds since it only processes a few dozen lines but in a large file with folds w0 and w$ can be very far apart and currently it's looping through every single line to add the highlight even though they are not in view. I tried setting the highlight.throttle option to a lower value and it did not help much. (This config value is also not documented). I'm attaching a video of the issue happening.

Screen.Recording.2024-07-02.at.2.46.00.PM.mov

Steps To Reproduce

  1. Open a large file (in my case it was a tree-sitter src/parser.c file)
  2. Fold all code blocks
  3. Scroll through the file

Expected Behavior

Ideally todo-comments wouldn't process all these folded lines that are not in view.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/todo-comments.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@mtrajano mtrajano added the bug Something isn't working label Jul 2, 2024
mtrajano added a commit to mtrajano/todo-comments.nvim that referenced this issue Jul 26, 2024
Fixes: folke#285

Currently on a window update such as `WinScroll` highlight_win is
looping through every line from from `w0` to `w$` to update the
highlights. On large files with very large folded regions these two
lines can be very far apart and highlighting every single line can be
costly even though they are not in view. This update adds a check to
skip over any liens hidden in a fold.
mtrajano added a commit to mtrajano/todo-comments.nvim that referenced this issue Jul 26, 2024
Fixes: folke#285

Currently on a window update such as `WinScroll` highlight_win is
looping through every line from from `w0` to `w$` to update the
highlights. On large files with very large folded regions these two
lines can be very far apart and highlighting every single line can be
costly even though they are not in view. This update adds a check to
skip over any lines hidden in a fold.
@mtrajano mtrajano changed the title bug: Performance issues on large files with folds bug: performance issues on large files with folds Jul 26, 2024
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Aug 26, 2024
Copy link
Contributor

github-actions bot commented Sep 2, 2024

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant