File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ struct Spec {
2424 custom_languages : Vec < CustomLanguageSpec > ,
2525}
2626
27+ const TREESITTER_MAX_RECURSION_DEPTH : usize = 128 ;
28+
2729const SYNTAX_LEVEL_GAP_COST : usize = 512 ;
2830const MISSING_OVERLAP_COST : usize = 512 ;
2931const PER_LINE_BREAK_LEVEL_GAP_COST : usize = 64 ;
@@ -542,7 +544,9 @@ impl<'t, 's: 't> RecursiveChunker<'s> {
542544 ) -> Result < ( ) > {
543545 match chunk. kind {
544546 ChunkKind :: TreeSitterNode { lang_config, node } => {
545- if !lang_config. terminal_node_kind_ids . contains ( & node. kind_id ( ) ) {
547+ if !lang_config. terminal_node_kind_ids . contains ( & node. kind_id ( ) )
548+ && atom_collector. curr_level < TREESITTER_MAX_RECURSION_DEPTH
549+ {
546550 let mut cursor = node. walk ( ) ;
547551 if cursor. goto_first_child ( ) {
548552 return self . collect_atom_chunks_from_iter (
You can’t perform that action at this time.
0 commit comments