From b59eba3ada13ee3ceb0f8decebd261e55b2baa2d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 16 Feb 2026 07:39:02 +0800 Subject: [PATCH] vim-patch:9.2.0007: cindent: recognizing labels within commented lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ä --- src/nvim/indent_c.c | 3 +++ test/old/testdir/test_cindent.vim | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 2a30573a0b..40e22f8c9a 100644 --- 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 index 345f005815..8a15529a41 100644 --- 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]