File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Test/test_script/format_text Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,24 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatAssignLeftExpressionList(std:
662662
663663std::shared_ptr<FormatElement> LuaFormatter::FormatComment (std::shared_ptr<LuaAstNode> comment)
664664{
665- return std::make_shared<TextElement>(comment);
665+ auto text = comment->GetText ();
666+ if (!text.empty () && text.back () > 0 && ::isspace (text.back ()) == 0 )
667+ {
668+ return std::make_shared<TextElement>(comment);
669+ }
670+ int i = static_cast <int >(text.size ()) - 1 ;
671+ for (; i >= 0 ; i--)
672+ {
673+ char ch = text[i];
674+ if (ch <= 0 || ::isspace (ch) == 0 )
675+ {
676+ break ;
677+ }
678+ }
679+
680+ text = text.substr (0 , i + 1 );
681+
682+ return std::make_shared<TextElement>(text, comment->GetTextRange ());
666683}
667684
668685std::shared_ptr<FormatElement> LuaFormatter::FormatBreakStatement (std::shared_ptr<LuaAstNode> breakNode)
Original file line number Diff line number Diff line change 2323
2424return -- fff
2525aaa + ccc ,bbb
26+
27+ -- wjgiowjiojg
28+ --[[ ]]
29+ local t = -- [[[[[[]]]]]]
30+ wgwjgjwiog --[[
31+
32+
33+ ]]
Original file line number Diff line number Diff line change 2323
2424return -- fff
2525 aaa + ccc , bbb
26+
27+ -- wjgiowjiojg
28+ --[[ ]]
29+ local t = -- [[[[[[]]]]]]
30+ wgwjgjwiog --[[
31+
32+
33+ ]]
You can’t perform that action at this time.
0 commit comments