Skip to content

Commit 4540436

Browse files
committed
IMPL #39
1 parent bde3e2f commit 4540436

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CodeService/src/LuaEditorConfig.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ void LuaEditorConfig::ParseFromSection(std::shared_ptr<LuaCodeStyleOptions> opti
243243
options->continuation_indent_size = std::stoi(configMap.at("continuation_indent_size"));
244244
}
245245

246+
if(configMap.count("statement_inline_comment_space")
247+
&& isNumber(configMap.at("statement_inline_comment_space")))
248+
{
249+
options->statement_inline_comment_space = std::stoi(configMap.at("statement_inline_comment_space"));
250+
}
251+
246252
if (configMap.count("local_assign_continuation_align_to_first_expression"))
247253
{
248254
options->local_assign_continuation_align_to_first_expression =

CodeService/src/LuaFormatter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatBlock(std::shared_ptr<LuaAstN
331331
{
332332
if (!last->GetChildren().empty() && last->GetChildren().back()->HasValidTextRange())
333333
{
334-
last->Add<KeepBlankElement>(1);
334+
last->Add<KeepBlankElement>(_options.statement_inline_comment_space);
335335
}
336336
last->AddChild(FormatComment(statement));
337337
}
@@ -359,7 +359,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatBlock(std::shared_ptr<LuaAstN
359359

360360
if (currentLine == nextLine)
361361
{
362-
statEnv->Add<KeepBlankElement>(1);
362+
statEnv->Add<KeepBlankElement>(_options.statement_inline_comment_space);
363363
statEnv->Add<TextElement>(next);
364364
++it;
365365
}
@@ -1676,7 +1676,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatAlignStatement(LuaAstNode::Ch
16761676
auto lastStatementEnv = env->LastValidElement();
16771677
if (lastStatementEnv)
16781678
{
1679-
lastStatementEnv->Add<KeepBlankElement>(1);
1679+
lastStatementEnv->Add<KeepBlankElement>(_options.statement_inline_comment_space);
16801680
lastStatementEnv->AddChild(FormatNode(nextChild));
16811681
}
16821682
//else 应该不存在这种情况

include/CodeService/LuaCodeStyleOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class LuaCodeStyleOptions
4040
*/
4141
int continuation_indent_size = 4;
4242

43+
int statement_inline_comment_space = 1;
4344

4445
bool local_assign_continuation_align_to_first_expression = false;
4546

0 commit comments

Comments
 (0)