commit b59eba3ada13ee3ceb0f8decebd261e55b2baa2d
parent 7d8653575f2a1170f0c7651f271c45a15a185d5e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 16 Feb 2026 07:39:02 +0800
vim-patch:9.2.0007: cindent: recognizing labels within commented lines
Problem: Comment lines which start like a label are recognized as a
label and indented based on that.
Solution: Check if the position is in a comment after recognizing a label
in cin_islabel (Anttoni Erkkilä)
closes: vim/vim#19397
https://github.com/vim/vim/commit/9af18686c7842c8002268d861e37f6ad46a9b641
Co-authored-by: Anttoni Erkkilä <anttoni.erkkila@protonmail.com>
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
@@ -370,6 +370,9 @@ static bool cin_islabel(void) // XXX
return false;
}
+ if (ind_find_start_CORS(NULL)) {
+ return false; // Don't accept a label in a comment or a raw string.
+ }
// Only accept a label if the previous line is terminated or is a case
// label.
pos_T cursor_save;
diff --git a/test/old/testdir/test_cindent.vim b/test/old/testdir/test_cindent.vim
@@ -1127,6 +1127,12 @@ func Test_cindent_1()
a();
}
+ void func() {
+ /* aaaaaa
+ bbbbb:
+ ccccccc */
+ }
+
/* end of AUTO */
[CODE]
@@ -2130,6 +2136,12 @@ func Test_cindent_1()
a();
}
+ void func() {
+ /* aaaaaa
+ bbbbb:
+ ccccccc */
+ }
+
/* end of AUTO */
[CODE]