Skip to content

Commit 69188f7

Browse files
committed
修复一些bug
1 parent a154bb9 commit 69188f7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CodeService/src/FormatElement/FormatContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void FormatContext::PrintBlank(int blank)
4343

4444
void FormatContext::PrintIndent(int indent, const std::string& indentString)
4545
{
46-
// 我始终认为使\t来排版就是垃圾
4746
for (int i = 0; i < indent; i++)
4847
{
4948
_os << indentString;

CodeService/src/LuaFormatter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ LuaFormatter::LuaFormatter(std::shared_ptr<LuaParser> luaParser, LuaCodeStyleOpt
4646
void LuaFormatter::BuildFormattedElement()
4747
{
4848
auto chunkNode = _parser->GetAst();
49-
50-
_env = FormatBlock(chunkNode->GetChildren().front());
49+
if (!chunkNode->GetChildren().empty())
50+
{
51+
_env = FormatBlock(chunkNode->GetChildren().front());
52+
}
53+
else
54+
{
55+
_env = std::make_shared<IndentElement>();
56+
}
5157
}
5258

5359
std::string LuaFormatter::GetFormattedText()

0 commit comments

Comments
 (0)