From b8009bbf2d890511d19a31ba0757fbbe53f5c092 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 2 Feb 2023 14:42:42 -0800 Subject: [PATCH] ; Fix error where we pass t to treesit-node-type in c-ts-common.el MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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. --- lisp/progmodes/c-ts-common.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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) -- 2.39.2