; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value.

This commit is contained in:
Yuan Fu 2022-12-01 21:19:14 -08:00
parent 2c4d92d30f
commit 520a4e12f8
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View 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