helix: Very slow *editing* of large files when tree-sitter is used

Summary

Certain markdown files are very slow to edit. In particular when they have a lot of lists. For example a CHANGELOG.md file from the helix repo is a enough to trigger it.

The problem is likely in grammar here, since neovim with tree-sitter works fine on it.

While this particular problem could be solved with slightly optimized, but less accurate grammar. However the issue manifests itself on any large file of any other type, just requires much larger file than ~600LoC(I’ve used 50K LoC C++ that I have around).

To avoid delay and input lag in those particular scenarios it would make sense to either run tree-sitter only on a part of the buffer (I’m not familiar how it works) or update it after the typing ended. Since right now you have a latency of like 2 seconds on 50K lines file of C++, which is impossible to work with.

Reproduction Steps

Try to edit CHANGELOG.md from the helix repo or any large file.

Helix log

No response

Platform

Linux

Terminal Emulator

alacritty

Helix Version

helix 22.05 (3cced1e3)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 8
  • Comments: 21 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I use git commit --verbose, which causes the COMMIT_EDITMSG files to contain the full diff of what’s being committed. At work, I just happened to commit changes weighing about ~400k lines of diff, all generated, and I experienced this slowness - each insert keystroke lagged by about a second. @kchibisov’s suggestion of :set-language text works like a charm as a workaround, for now.

Still happening with 23.03, for what it’s worth.

While my original issue is resolved with the markdown.

I’d think I’ll leave a real world example of a big file that is well formatted and not some dump of the logging utility, since I’ve mentioned in original report a C++ file, but I haven’t showed it.

So that’s the file I’ve referred to originally wrt my C++ quote.

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86ISelLowering.cpp

The :set-language text makes a normal editing experience(same perf as file of any other size).

Just wanted to mention #4146 here. Maybe that fixed some problems, but probably not all of them.