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

From: Juri Linkov <[email-masked]>
Date: Fri, 06 Jun 2025 18:42:57 +0300

>> 1. M-: (setq outline-minor-mode-cycle t)
>> 2. M-: (setq outline-minor-mode-use-buttons t)
>> 3. M-: (setq debug-on-error t)
>> 4. C-x p f test/manual/indent/html-multi.html
>> 5. M-x load-library RET treesit-x
>> 6. M-x liquid-generic-ts-mode
>> 7. M-x outline-minor-mode
>> 8. move point to the first 's' in 'script' on line 19
>> 9. type 'M-d' ('kill-word')
>
> Aha, I reproduced it. It didn’t happen when I kill-word, but happened when
> I undo.

This is what I observe too: when it doesn't fail on edit,
then in any case it fails on undo.

> I’m still trying to understand why the node-outdated error can
> happen. Each parser has a tick, which is incremented whenever it
> re-parses. When we create a node from the parser, the node inherits the
> current tick number of the parser. We only consider a node outdated when
> its tick is less than its parser’s tick, meaning the parser re-parsed after
> the node is created. For a parser to re-parse, it has to a) receive
> a buffer edit or b) change it’s ranges; and then someone needs to request
> a node from it.
>
> That means in the following backtrace, the parser received a buffer
> edit or changed its ranges after the `prev` node is created. And
> that’s baffling to me.

Maybe calling this from after-change-functions affects the order of
calling parser functions.