[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 520a4e12f8e 1/2: ; * lisp/treesit.el (treesit-end-of-defun): Gu
From: |
Yuan Fu |
Subject: |
emacs-29 520a4e12f8e 1/2: ; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value. |
Date: |
Sat, 3 Dec 2022 17:50:12 -0500 (EST) |
branch: emacs-29
commit 520a4e12f8e6e42d0c66cc6b3cf3be05c411fe6f
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; * lisp/treesit.el (treesit-end-of-defun): Guard against nil value.
---
lisp/treesit.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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