Skip to content

Commit 9cc3f0b

Browse files
committed
Close #106
1 parent 9c7b7cb commit 9cc3f0b

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

CodeService/src/Format/Analyzer/LineBreakAnalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void LineBreakAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {
3434
case LuaSyntaxNodeKind::Block: {
3535
auto children = syntaxNode.GetChildren(t);
3636
if (syntaxNode.GetParent(t).IsSingleLineNode(t)) {
37-
if (children.size() == 1) {
37+
if (children.size() <= 1) {
3838
auto spaceAnalyzer = f.GetAnalyzer<SpaceAnalyzer>();
3939
spaceAnalyzer->SpaceAround(syntaxNode, t);
4040
continue;

Test/src/FormatResult_unitest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,4 +898,14 @@ ddd = 123;
898898
899899
pcall(f, 1, 2, 3); do return true end
900900
)"));
901+
}
902+
903+
TEST(Format, feature_106) {
904+
EXPECT_TRUE(TestHelper::TestFormatted(
905+
R"(
906+
local empty = function () end
907+
)",
908+
R"(
909+
local empty = function() end
910+
)"));
901911
}

Test/src/FormatStyle_unitest.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,15 @@ TEST(FormatByStyleOption, space_before_function_open_parenthesis) {
396396
function f() end
397397
)",
398398
R"(
399-
function f ()
400-
end
399+
function f () end
401400
)", style));
402401
style.space_before_function_open_parenthesis = false;
403402
EXPECT_TRUE(TestHelper::TestFormatted(
404403
R"(
405404
function f() end
406405
)",
407406
R"(
408-
function f()
409-
end
407+
function f() end
410408
)", style));
411409
}
412410

Test2/src/FormatTest2.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88

99
int main() {
1010
std::string buffer = R"(
11-
local t; Init(v)
12-
13-
14-
local d =123
11+
local empty = function () end
1512
1613
)";
1714

include/Util/InfoTree/InfoTree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "InfoKind.h"
44
#include "InfoNode.h"
55
#include <string>
6+
#include <vector>
67
#include <unordered_map>
78

89
class InfoTree {

0 commit comments

Comments
 (0)