diff options
author | Yuan Fu <casouri@gmail.com> | 2022-12-01 21:19:14 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-12-03 14:49:37 -0800 |
commit | 520a4e12f8e6e42d0c66cc6b3cf3be05c411fe6f (patch) | |
tree | 15a4b417a7fea2556237d4980756381ea6f411d5 | |
parent | 2c4d92d30f65860604e4a240edbc109198cfb767 (diff) | |
download | emacs-520a4e12f8e6e42d0c66cc6b3cf3be05c411fe6f.tar.gz |
; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value.
-rw-r--r-- | lisp/treesit.el | 7 |
1 files changed, 6 insertions, 1 deletions
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 |