summaryrefslogtreecommitdiff
path: root/lisp/progmodes/c-ts-mode.el
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-03-05 15:07:58 -0800
committerYuan Fu <casouri@gmail.com>2023-03-05 15:07:58 -0800
commitd724d7d6785db7224b5a9f04b092d8671bddd290 (patch)
treef7e58534ea56f8b56b22dab7cd3a9e3c9499694e /lisp/progmodes/c-ts-mode.el
parent7292b24c80143d697870a670963f136db375580b (diff)
downloademacs-d724d7d6785db7224b5a9f04b092d8671bddd290.tar.gz
emacs-d724d7d6785db7224b5a9f04b092d8671bddd290.tar.bz2
emacs-d724d7d6785db7224b5a9f04b092d8671bddd290.zip
Fix c-ts-mode indentation
Mentioned in bug#61893, although not the subject of it. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--anchor-prev-sibling): Fix the child index for preproc_else and preproc_elif case. * test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: New test.
Diffstat (limited to 'lisp/progmodes/c-ts-mode.el')
-rw-r--r--lisp/progmodes/c-ts-mode.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index ee4a3bb2de0..2c534aa785a 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -292,8 +292,10 @@ PARENT and BOL are like other anchor functions."
(setq prev-sibling (treesit-node-child prev-sibling 2)))
;; Get the last statement in the preproc. Tested by
;; "Prev-Sibling When Prev-Sibling is Preproc" test.
- ((or "preproc_if" "preproc_ifdef" "preproc_elif" "preproc_else")
+ ((or "preproc_if" "preproc_ifdef")
(setq prev-sibling (treesit-node-child prev-sibling -2)))
+ ((or "preproc_elif" "preproc_else")
+ (setq prev-sibling (treesit-node-child prev-sibling -1)))
;; If the start of the previous sibling isn't at the
;; beginning of a line, something's probably not quite
;; right, go a step further.