Skip to content

Commit 99e4ab2

Browse files
Virginia Senioriabrammool
authored andcommitted
patch 9.0.1426: indent wrong after "export namespace" in C++
Problem: Indent wrong after "export namespace" in C++. Solution: Skip over "inline" and "export" in any order. (Virginia Senioria, closes #12134, closes #12133)
1 parent 3ea6238 commit 99e4ab2

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/cindent.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,9 @@ cin_is_cpp_namespace(char_u *s)
769769

770770
s = cin_skipcomment(s);
771771

772-
if (STRNCMP(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6])))
772+
// skip over "inline" and "export" in any order
773+
while ((STRNCMP(s, "inline", 6) == 0 || STRNCMP(s, "export", 6) == 0)
774+
&& (s[6] == NUL || !vim_iswordc(s[6])))
773775
s = cin_skipcomment(skipwhite(s + 6));
774776

775777
if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9])))

src/testdir/test_cindent.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4406,6 +4406,18 @@ def Test_cindent_47()
44064406
inline/* test */namespace {
44074407
111111111111111111;
44084408
}
4409+
export namespace {
4410+
111111111111111111;
4411+
}
4412+
export inline namespace {
4413+
111111111111111111;
4414+
}
4415+
export/* test */inline namespace {
4416+
111111111111111111;
4417+
}
4418+
inline export namespace {
4419+
111111111111111111;
4420+
}
44094421

44104422
/* invalid namespaces use block indent */
44114423
namespace test test2 {
@@ -4509,6 +4521,18 @@ def Test_cindent_47()
45094521
inline/* test */namespace {
45104522
111111111111111111;
45114523
}
4524+
export namespace {
4525+
111111111111111111;
4526+
}
4527+
export inline namespace {
4528+
111111111111111111;
4529+
}
4530+
export/* test */inline namespace {
4531+
111111111111111111;
4532+
}
4533+
inline export namespace {
4534+
111111111111111111;
4535+
}
45124536

45134537
/* invalid namespaces use block indent */
45144538
namespace test test2 {

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1426,
698700
/**/
699701
1425,
700702
/**/

0 commit comments

Comments
 (0)