From: Yuan Fu Date: Thu, 2 Feb 2023 22:42:42 +0000 (-0800) Subject: ; Fix error where we pass t to treesit-node-type in c-ts-common.el X-Git-Tag: emacs-29.0.90~533 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b8009bbf2d890511d19a31ba0757fbbe53f5c092;p=emacs.git ; Fix error where we pass t to treesit-node-type in c-ts-common.el * lisp/progmodes/c-ts-common.el: (c-ts-common-statement-offset): Move the form that sets node to t down, also add a check for node’s nullness. --- diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index c13b01aae5c..fd16c9713a5 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -294,16 +294,17 @@ it adds an extra level, except for the top-level. PARENT is NODE's parent." (let ((level 0)) + ;; If NODE is a opening/closing bracket on its own line, take off + ;; one level because the code below assumes NODE is a statement + ;; _inside_ a {} block. + (when (and node + (string-match-p c-ts-common-indent-block-type-regexp + (treesit-node-type node))) + (cl-decf level)) ;; If point is on an empty line, NODE would be nil, but we pretend ;; there is a statement node. (when (null node) (setq node t)) - ;; If NODE is a opening bracket on its own line, take off one - ;; level because the code below assumes NODE is a statement - ;; _inside_ a {} block. - (when (string-match-p c-ts-common-indent-block-type-regexp - (treesit-node-type node)) - (cl-decf level)) ;; Go up the tree and compute indent level. (while (if (eq node t) (setq node parent)