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

Tree-sitter match limit is insufficient sometimes #6509

Open
woojiq opened this issue Mar 31, 2023 · 4 comments
Open

Tree-sitter match limit is insufficient sometimes #6509

woojiq opened this issue Mar 31, 2023 · 4 comments
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug

Comments

@woojiq
Copy link
Contributor

woojiq commented Mar 31, 2023

Summary

In short: the text is colored not immediately, but if you scroll down a little.

Self describing video: asciicast

P.S. Give this issue a better name, I don't know what to call it properly 😂

Reproduction Steps

I tried this:

  1. Clone the serde_json repo https://github.com/serde-rs/json
  2. Open the src/lib.rs file
  3. Go to the line +-310 and scroll down, you will see unhighlighted text, scroll down a bit and the text will be colored.

I expected this to happen:
Average beautiful highlighting:)

Instead, this happened:
Part of the text does not color out immediately.

Helix log

~/.cache/helix/helix.log
please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines
nothing related even with `-vvv`

Platform

Linux/Nixos-unstable

Terminal Emulator

wezterm 20230326-111934-3666303c

Helix Version

helix 23.03

@woojiq woojiq added the C-bug Category: This is a bug label Mar 31, 2023
@the-mikedavis
Copy link
Member

I think this is caused by the tree-sitter match limit (#4707), I saw similar behavior with Erlang when matching a complicated pattern against a large subtree (#4830).

@the-mikedavis the-mikedavis added the A-tree-sitter Area: Tree-sitter label Mar 31, 2023
@woojiq
Copy link
Contributor Author

woojiq commented Apr 1, 2023

I've built the helix myself with the next change:

const TREE_SITTER_MATCH_LIMIT: u32 = 256;

-const TREE_SITTER_MATCH_LIMIT: u32 = 256; 
+const TREE_SITTER_MATCH_LIMIT: u32 = 512;

And now it works fine. Right now I don't know how to check the penalty speed properly, is it the start time of the helix app or what? In any case, I don't think just changing this variable is a good idea. In my opinion, it would be better to set these settings for different languages or give users access to this option, so it would be possible to change temporarily for one file because not everyone needs that much (personally, it doesn't spoil the quality of my life 🙂). Though I'm not sure treesitter can change its settings at runtime.

@woojiq woojiq changed the title Rust highlighting problem with a long list of attributes Tree-sitter match limit is insufficient sometimes Apr 16, 2023
@Rickyfs

This comment was marked as off-topic.

@pascalkuthe

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants