Subject: bug#78402: treesit after-change-functions

From: Juri Linkov <[email-masked]>
Date: Thu, 15 May 2025 20:06:14 +0300

> Btw, what’s the issue we’re trying to fix here? If some lisp want to
> have up-to-date ranges, it can just call treesit--pre-redisplay or
> treesit-update-ranges. Why do we get the node-outdated error?

One example where this is needed is updating the outline buttons
based on the changed text in a ts-mode buffer.

Either after-change-functions or jit-lock-function calls
outline--fix-up-all-buttons that uses treesit-outline-search
that requires the updated ranges.

I see that treesit-indent and treesit-indent-region
explicitly calls treesit-update-ranges at the beginning.
Is it how treesit command are intended to update ranges
for themselves?  It would be inefficient to call
treesit-update-ranges in treesit-outline-search.