aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorMichael Davis2022-11-21 09:13:59 +0000
committerGitHub2022-11-21 09:13:59 +0000
commit0b2bb061b95b60c51f018f541e622b731ddd14ef (patch)
tree9413e06adeade8087cf2a613e4fea8e6cbc41e9e /helix-core
parentbbde897ac39991620a9b6e9e5c742ab3b97b1fbe (diff)
Bump TREE_SITTER_MATCH_LIMIT to 256 (#4830)
The limit of 64 breaks some highlighting in Erlang files with complicated record definitions. Bumping to 256 seems to work on all files I have seen.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 93bd7fe9..b567a8ab 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -354,24 +354,25 @@ impl<'a> CapturedNode<'a> {
}
}
-/// The number of matches a TS cursor can at once to avoid performance problems for medium to large files.
-/// Set with `set_match_limit`.
-/// Using such a limit means that we lose valid captures in, so there is fundamentally a tradeoff here.
+/// The maximum number of in-progress matches a TS cursor can consider at once.
+/// This is set to a constant in order to avoid performance problems for medium to large files. Set with `set_match_limit`.
+/// Using such a limit means that we lose valid captures, so there is fundamentally a tradeoff here.
///
///
/// Old tree sitter versions used a limit of 32 by default until this limit was removed in version `0.19.5` (must now be set manually).
/// However, this causes performance issues for medium to large files.
/// In helix, this problem caused treesitter motions to take multiple seconds to complete in medium-sized rust files (3k loc).
+///
+///
/// Neovim also encountered this problem and reintroduced this limit after it was removed upstream
/// (see <https://github.com/neovim/neovim/issues/14897> and <https://github.com/neovim/neovim/pull/14915>).
/// The number used here is fundamentally a tradeoff between breaking some obscure edge cases and performance.
///
///
-/// A value of 64 was chosen because neovim uses that value.
-/// Neovim chose this value somewhat arbitrarily (<https://github.com/neovim/neovim/pull/18397>) adjusting it whenever issues occur in practice.
-/// However this value has been in use for a long time and due to the large userbase of neovim it is probably a good choice.
-/// If this limit causes problems for a grammar in the future, it could be increased.
-const TREE_SITTER_MATCH_LIMIT: u32 = 64;
+/// Neovim chose 64 for this value somewhat arbitrarily (<https://github.com/neovim/neovim/pull/18397>).
+/// 64 is too low for some languages though. In particular, it breaks some highlighting for record fields in Erlang record definitions.
+/// This number can be increased if new syntax highlight breakages are found, as long as the performance penalty is not too high.
+const TREE_SITTER_MATCH_LIMIT: u32 = 256;
impl TextObjectQuery {
/// Run the query on the given node and return sub nodes which match given