]> git.eshelyaron.com Git - emacs.git/commit
Improve treesit-forward-sexp behavior for leaf nodes (bug#68899)
authorYuan Fu <casouri@gmail.com>
Sun, 4 Feb 2024 05:24:29 +0000 (21:24 -0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 7 Feb 2024 10:50:56 +0000 (11:50 +0100)
commitb93dd3f1a7c7662f891bbdf36f90db2b3310e1e8
treed1b4bcc4b1d0f3f2470ecd70a6e881eb9fa580ff
parent242bc96ab3936f5cdd2983d84be499803baef957
Improve treesit-forward-sexp behavior for leaf nodes (bug#68899)

treesit-forward-sexp uses treesit--navigate-thing with 'restricted'
tactic.  In this tactic we don't move over the parent thing.  However,
this makes forward-sexp useless for symbols when point is in the
symbol rather than at the beginning of it: in that case, the symbol is
considered parent and treesit-forward-sexp won't move to the end of
it.

To solve that, we allow to move across the parent even in 'restricted'
mode if the parent is a leaf thing.

Here, "leaf thing" is defined as "doesn't have any child 'thing'
inside it".

* lisp/treesit.el (treesit--navigate-thing): Move over parent in
'restricted' tactic if the parent is a leaf thing.

(cherry picked from commit 9dbbf93a4a08f71cf5f2278ec2a22a722fe0e0f7)
lisp/treesit.el