all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#61529: 30.0.50; tree-sitter: weird off-by-one error but only in css-ts-mode(?) with `treesit-node-at'
@ 2023-02-15  8:25 Mickey Petersen
  2023-02-15 13:42 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Mickey Petersen @ 2023-02-15  8:25 UTC (permalink / raw)
  To: 61529


Here's a strange one.

I don't know where to point the finger here exactly, but I think
`treesit-node-at' might have a small bug in it somewhere.


Consider this `css-ts-mode' code:

    a {
      background: linear-gradient(|210deg, rgba(255,82,41,1) 0%, rgba(251,165,85,1) 54%, rgba(163,73,73,1) 100%);
    }

Let | be point.

Engage `treesit-inspect-mode' and you'll see it asserts that point is
at '('. OK, so that could easily be a glitch in that implementation,
but let's probe further.

With point at '2', then I'd expect `treesit-node-at' to yield that node. But it does not:

(cons (point) (treesit-node-at (point)))

=> (34 . #<treesit-node "(" in 34-35>)

Move back one point

(cons (1- (point)) (treesit-node-at (1- (point)))) 
 
=> (35 . #<treesit-node "(" in 34-35>)

Move *forward* one and it does, but it gives us `unit' but I'd expect
`integer_value` as per the explorer (and indeed the tree.)

(cons (1+ (point)) (treesit-node-at (1+ (point))))

=> (36 . #<treesit-node unit in 38-41>)

Again but with the TS implementation `treesit-node-on`:

(cons (point) (treesit-node-on (point) (point)))

=> (35 . #<treesit-node integer_value in 35-41>)

And now we get the right node.









^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-02-17 15:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15  8:25 bug#61529: 30.0.50; tree-sitter: weird off-by-one error but only in css-ts-mode(?) with `treesit-node-at' Mickey Petersen
2023-02-15 13:42 ` Eli Zaretskii
2023-02-15 13:42   ` Mickey Petersen
2023-02-15 18:35     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 19:01       ` Mickey Petersen
2023-02-15 19:42         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-16 19:48           ` Mickey Petersen
2023-02-16 21:26         ` Dmitry Gutov
2023-02-16 21:34       ` Dmitry Gutov
2023-02-17  6:16         ` Eli Zaretskii
2023-02-17  7:24           ` Mickey Petersen
2023-02-17 15:11           ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.