diff --git a/lisp/treesit.el b/lisp/treesit.el index 4f40a3055b5..c018afc1e98 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -4313,7 +4313,7 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in (comment-p (and comment-thing (eq beg (treesit-node-start comment-thing)))) (thing (if comment-p comment-thing block-thing)) (end (if thing (min (1+ (treesit-node-start thing)) (point-max))))) - (when (<= end (point)) + (when (and end (<= end (point))) (setq end (treesit-node-end thing))) (when (and end (<= end maxp)) (goto-char end)