Yep, that sounds easier. And the performance should be about the same, even if
it'd have a bit extra overhead in those theoretical complex cases.
Ok, I pushed a commit to master that does just that. I tried with C’s block
comment, and php-ts-mode. Everything seems to work fine.
I also added treesit-primary-parser. This is supposed to be another
configuration variable that a major mode should set. I’ve encountered various
cases where knowing the primary parser (parser that parses the entire buffer
rather than just a subset of it) would be very helpful. Treesit-primary-parser
can be auto-guessed if major mode doesn’t set it, so it shouldn’t break
anything. I’d love to know yours and Stefan’s thoughts on it.