Subject: bug#77255: Treesit font-lock override for embed ranges

From: Juri Linkov <[email-masked]>
Date: Wed, 02 Apr 2025 09:55:18 +0300

>>> Everything works nicely in the attached example of the liquid major mode
>>> where liquid is the primary parser.  Currently it copies settings
>>> from mhtml-ts-mode.  But later I'll try to inherit from mhtml-ts-mode.
>> 
>> However, with inheritance that causes several changes of the
>> primary parser and several calls to treesit-major-mode-setup
>> during the ts-mode initialization, sometimes I get such backtraces
>> only after the first edit:
>> 
>> Debugger entered--Lisp error: (treesit-node-outdated #<treesit-node-outdated>)
>>  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_78>(beg #<treesit-node-outdated>)
>>  treesit-navigate-thing(35 1 beg html-ts-mode--outline-predicate)
>> 
>> Could you suggest where to look?
>
> Could it be that you passed a lambda/closure to treesit-navigate-thing
> which contains a tree-sitter node?

Thanks, indeed this is because outline-minor-mode was activated
too early on the wrong hook.  It should be activated on the last hook,
i.e. liquid-generic-ts-mode-hook instead of the parent's mhtml-ts-mode-hook.