GNU bug report logs - #61529
30.0.50; tree-sitter: weird off-by-one error but only in css-ts-mode(?) with `treesit-node-at'

Previous Next

Package: emacs;

Reported by: Mickey Petersen <mickey <at> masteringemacs.org>

Date: Wed, 15 Feb 2023 08:32:01 UTC

Severity: normal

Found in version 30.0.50

Fixed in version 29.1

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 61529 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>,
 Mickey Petersen <mickey <at> masteringemacs.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61529 <at> debbugs.gnu.org
Subject: Re: bug#61529: 30.0.50; tree-sitter: weird off-by-one error but only
 in css-ts-mode(?) with `treesit-node-at'
Date: Thu, 16 Feb 2023 23:34:58 +0200
On 15/02/2023 20:35, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> So the docstring of treesit-node-at states:

Looking at the code, this change might describe it better:

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 749781894b8..6e53b3d4c4a 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -166,10 +166,13 @@ treesit-node-at
 A leaf node is a node that doesn't have any child nodes.

 The returned node's span covers POS: the node's beginning is before
-or at POS, and the node's end is at or after POS.
+or at POS, and the node's end is after POS.

-If no leaf node's span covers POS (e.g., POS is on whitespace
-between two leaf nodes), return the first leaf node after POS.
+If no such node is found, but a leaf node ends at POS, it's
+returned.
+
+Otherwise (e.g., when POS is on whitespace between two leaf
+nodes), return the first leaf node after POS.

 If there is no leaf node after POS, return the first leaf node
 before POS.





This bug report was last modified 2 years and 149 days ago.

Previous Next


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