Skip to content

Fix TS freezing the editor - #7028

Merged
archseer merged 2 commits into
masterfrom
picker_highlight_freezes
May 18, 2023
Merged

Fix TS freezing the editor#7028
archseer merged 2 commits into
masterfrom
picker_highlight_freezes

Conversation

@pascalkuthe

@pascalkuthe pascalkuthe commented May 12, 2023

Copy link
Copy Markdown
Member

Fixes #6697
Closes #338

This PR addresses TS syntax highlighting freezing the UI loop in two separate ways:

  • It uses the parser timeout mechanism in TS to limit all TS parsing to 500ms. If parsing exceeds 500ms, its canceled and TS is automatically disabled for that buffer. This is preferable to a fixed size limit (as suggested in Disabling tree-sitter on big files #338) as it takes different CPU speeds/grammar speeds into account (and future optimizations in the parser/TS). If parsing takes longer than 500ms the editor always feels laggy.
  • In the picker syntax highlighting is now performed in a background thread to avoid micro stutters in the UI (if trying to move after a short a delay)

@pascalkuthe pascalkuthe added A-tree-sitter Area: Tree-sitter A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate S-waiting-on-review Status: Awaiting review from a maintainer. labels May 12, 2023
@pascalkuthe
pascalkuthe requested review from sudormrfbin and removed request for sudormrfbin May 12, 2023 21:17
@archseer

Copy link
Copy Markdown
Member
  • This is preferable to a fixed size limit

I still think there should be an upper bound but we can set it to something really high (200~500MB?)

@archseer
archseer merged commit b070533 into master May 18, 2023
@archseer
archseer deleted the picker_highlight_freezes branch May 18, 2023 06:23
@alexmo1997

Copy link
Copy Markdown

Is there any way to disable this?
I have some json files I would like to go through with helix (for which syntax highlighting would be great), and I'm fine with waiting a few seconds when opening them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-helix-term Area: Helix term improvements A-tree-sitter Area: Tree-sitter E-medium Call for participation: Experience needed to fix: Medium / intermediate S-waiting-on-review Status: Awaiting review from a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling tree-sitter on big files 100% CPU usage in file picker

3 participants