From: Yuan Fu Date: Fri, 2 Dec 2022 05:19:14 +0000 (-0800) Subject: ; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value. X-Git-Tag: emacs-29.0.90~1357 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=520a4e12f8e6e42d0c66cc6b3cf3be05c411fe6f;p=emacs.git ; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value. --- diff --git a/lisp/treesit.el b/lisp/treesit.el index 0de0e283c3b..f3c03daf7e0 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -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