Skip to content

Commit 7443f86

Browse files
author
Jonathan Coe
committed
[clang-format] insert space after C# keyword var in var (key, value)
Reviewers: krasimir, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Tags: #clang-format, #clang Differential Revision: https://reviews.llvm.org/D79008
1 parent edb7786 commit 7443f86

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
30533053
if (Left.is(TT_CSharpNullConditionalLSquare))
30543054
return Style.SpacesInSquareBrackets;
30553055

3056+
// space after var in `var (key, value)`
3057+
if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
3058+
return true;
3059+
30563060
// space between keywords and paren e.g. "using ("
30573061
if (Right.is(tok::l_paren))
30583062
if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))

clang/unittests/Format/FormatTestCSharp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ TEST_F(FormatTestCSharp, CSharpSpaces) {
698698
verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
699699

700700
verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
701+
verifyFormat(R"(var (key, value))", Style);
701702

702703
// Not seen as a C-style cast.
703704
verifyFormat(R"(//

0 commit comments

Comments
 (0)