Subject: bug#77848: 31.0.50; treesit-update-ranges: offset setting is ignored for local parsers

From: Roman Rudakov <[email-masked]>
Date: Fri, 18 Apr 2025 09:32:00 +0200

Yuan Fu <[email-masked]> writes:

>> On Apr 16, 2025, at 11:24 PM, Juri Linkov <[email-masked]> wrote:
>>
>> Cc-ing Yuan for the help.
>>
>>> Hello, I've noticed that when defining 'treesit-range-settings' 
>>> using the
>>> 'treesit-range-rules helper function, such as:
>>>
>>> (treesit-range-rules
>>> :embed 'markdown-inline
>>> :host 'clojure
>>> :offset '(1 . -1)
>>> :local t
>>> (clojure-ts--docstring-query '@capture))
>>>
>>> The ':offset' setting doesn't have any effect.
>>>
>>> After debugging the 'treesit-update-ranges' function, I noticed 
>>> that it
>>> calls 'treesit--update-range-1', which in turn calls
>>> 'treesit--update-ranges-local' if ':local t' is
>>> specified. 'treesit--update-ranges-local' does not accept offset 
>>> as an
>>> argument, although it is mentioned in its documentation string:
>>>
>>>> OFFSET is a cons of start and end offsets that are applied to the 
>>>> range
>>>> for the local parser.
>>>
>>> This discrepancy between the documented behavior and the actual
>>> implementation of 'treesit--update-ranges-local' regarding the 
>>> offset
>>> argument might be a bug.
>
> Yes, it’s indeed a bug. I’ve pushed a fix for it. Thanks to you 
> both!
>
> Yuan

Thank you!

Would it be possible to also install the fix on emacs-30 branch?
--
Best regards, Roman