Skip to content

Commit 9d2bb7a

Browse files
committed
修复算法问题
1 parent 8923a00 commit 9d2bb7a

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project(LuaCodeStyle)
44

55
set(CMAKE_CXX_STANDARD 20)
66

7-
option(BuildAsLuaLib "Build for lua dll" ON)
7+
option(BuildAsLuaLib "Build for lua dll" OFF)
88
option(BuildCodeFormat "Build CodeFormat" ON)
99
option(BuildCodeFormatServer "Build CodeFormatServer" ON)
1010
option(EnableTest "Test project" ON)

CodeService/src/LuaFormatter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatCallArgList(std::shared_ptr<L
10931093
{
10941094
env->Add<KeepElement>(1);
10951095
}
1096-
else if (child->GetText() == "("
1096+
else if (child->GetText() == "("
10971097
&& _options.keep_one_space_between_call_args_and_parentheses
10981098
&& children.size() > 2)
10991099
{
@@ -1191,7 +1191,11 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatParamList(std::shared_ptr<Lua
11911191
else if (child->GetText() == ")")
11921192
{
11931193
env->AddChild(paramListLayoutEnv);
1194-
env->Add<KeepElement>(0);
1194+
if (!paramListLayoutEnv->GetChildren().empty())
1195+
{
1196+
env->Add<KeepElement>(0);
1197+
}
1198+
11951199
env->Add<TextElement>(child);
11961200
}
11971201
else

Test/src/CodeFormatTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ int main(int argc, char* argv[])
122122
return -1;
123123
}
124124

125-
126125
std::filesystem::path workRoot(commandLine.Get<std::string>("work-directory"));
127126
std::vector<std::string> luaFiles;
128127

@@ -151,6 +150,10 @@ int main(int argc, char* argv[])
151150

152151
success &= passed;
153152
std::cout << format("test format {} ... {}", path, passed ? "passed" : "false") << std::endl;
153+
154+
passed = TestFormatted(formattedText, formattedText, options);
155+
success &= passed;
156+
std::cout << format("test format stability {} ... {}", path, passed ? "passed" : "false") << std::endl;
154157
}
155158
}
156159
else if (target == "CheckGrammar")

Test/test_script/format_text_shouldbe/expressionList.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local t2 = c2(function()
66
end), bbbb, ccc, function() end,
77
function(
88

9-
)
9+
)
1010
end
1111

1212
function ff()

0 commit comments

Comments
 (0)