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

Previous Next

Package: emacs;

Reported by: Roman Rudakov <rrudakov <at> fastmail.com>

Date: Wed, 16 Apr 2025 19:06:03 UTC

Severity: normal

Found in version 31.0.50

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 77848-done <at> debbugs.gnu.org (full text, mbox):

From: Roman Rudakov <rrudakov <at> fastmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 77848-done <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#77848: 31.0.50; treesit-update-ranges: offset setting is
 ignored for local parsers
Date: Fri, 18 Apr 2025 09:32:00 +0200
Yuan Fu <casouri <at> gmail.com> writes:

>> On Apr 16, 2025, at 11:24 PM, Juri Linkov <juri <at> linkov.net> 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




This bug report was last modified 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.