Subject: Re: bug#77848: 31.0.50; treesit-update-ranges: offset setting is ignored for local parsers
From: Yuan Fu <[email-masked]>
To: Juri Linkov <[email-masked]>
Cc: Roman Rudakov <[email-masked]>, [email-masked]
Date: Thu, 17 Apr 2025 16:44:42 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

> 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