On Sat, Feb 3, 2024 at 12:42 AM João Távora wrote: > > This doesn't seem to break tests, assuming it's not in these 3 there > > were skipped because I don't have the grammar installed. > > Despite that, I think it's still wrong :-/ Now it moves too much, > i.e. it never stops moving. This looks more promising. Works well in my tests. diff --git a/lisp/treesit.el b/lisp/treesit.el index c6b9d8ff4bc..cad7497fb74 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2579,9 +2579,12 @@ treesit--navigate-thing (setq parent (treesit-node-top-level parent thing t) prev nil next nil)) - ;; If TACTIC is `restricted', the implementation is very simple. + ;; If TACTIC is `restricted', the implementation is reasonably simple. (if (eq tactic 'restricted) - (setq pos (funcall advance (if (> arg 0) next prev))) + (setq pos (funcall advance (cond ((and (null next) (null prev)) + parent) + ((> arg 0) next) + (t prev)))) ;; For `nested', it's a bit more work: ;; Move... (if (> arg 0)