Skip to content

Commit 9d42b2d

Browse files
committed
fix sumenko_1921
1 parent bb4cdbc commit 9d42b2d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CodeService/src/Format/Analyzer/SpaceAnalyzer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ void SpaceAnalyzer::Analyze(FormatState &f, const LuaSyntaxTree &t) {
5050
if (p.IsNode(t) && p.GetSyntaxKind(t) == LuaSyntaxNodeKind::BinaryExpression) {
5151
SpaceAround(syntaxNode, t, f.GetStyle().space_around_math_operator ? 1 : 0);
5252
} else {
53-
SpaceLeft(syntaxNode, t);
5453
SpaceRight(syntaxNode, t, 0);
54+
auto rightSiblingKind = syntaxNode.GetNextSibling(t).GetSyntaxKind(t);
55+
SpaceRight(syntaxNode, t, rightSiblingKind == LuaSyntaxNodeKind::UnaryExpression ? 1 : 0);
5556
}
5657
break;
5758
}

Test/src/FormatResult_unitest.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,16 @@ local t = nil, {
628628
sql = true
629629
}
630630
)"));
631+
}
632+
633+
TEST(Format, sumenko_1921) {
634+
EXPECT_TRUE(TestHelper::TestFormatted(
635+
R"(
636+
p(-1)
637+
t[-1] = -1
638+
)",
639+
R"(
640+
p(-1)
641+
t[-1] = -1
642+
)"));
631643
}

0 commit comments

Comments
 (0)