]> git.eshelyaron.com Git - emacs.git/commitdiff
; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value.
authorYuan Fu <casouri@gmail.com>
Fri, 2 Dec 2022 05:19:14 +0000 (21:19 -0800)
committerYuan Fu <casouri@gmail.com>
Sat, 3 Dec 2022 22:49:37 +0000 (14:49 -0800)
lisp/treesit.el

index 0de0e283c3bd8b6f8ca8b1bc8a7b30ced6285548..f3c03daf7e0d791731dfeb5968010d79c9e638d8 100644 (file)
@@ -1614,7 +1614,12 @@ ARG is the same as in `beginning-of-defun'."
   (let* ((node (treesit-search-forward
                 (treesit-node-at (point)) treesit-defun-type-regexp t t))
          (top (treesit--defun-maybe-top-level node)))
-    (goto-char (treesit-node-end top))))
+    ;; Technically `end-of-defun' should only call this function when
+    ;; point is at the beginning of a defun, so TOP should always be
+    ;; non-nil, but things happen, and we want to be safe, so check
+    ;; for TOP anyway.
+    (when top
+      (goto-char (treesit-node-end top)))))
 
 ;;; Activating tree-sitter