diff options
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 9226e89..ff06625 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -8203,7 +8203,20 @@ private: | |||
| 8203 | incIndentOffset(); | 8203 | incIndentOffset(); |
| 8204 | auto metatable = x->new_ptr<SimpleTable_t>(); | 8204 | auto metatable = x->new_ptr<SimpleTable_t>(); |
| 8205 | ast_sel<false, Exp_t, TableBlock_t> metatableItem; | 8205 | ast_sel<false, Exp_t, TableBlock_t> metatableItem; |
| 8206 | ast_node* lastValueNode = values.back(); | ||
| 8207 | if (!_config.reserveComment) { | ||
| 8208 | for (auto it = values.rbegin(); it != values.rend(); ++it) { | ||
| 8209 | auto node = *it; | ||
| 8210 | if (!ast_is<YueLineComment_t, YueMultilineComment_t, EmptyLine_t>(node)) { | ||
| 8211 | lastValueNode = node; | ||
| 8212 | break; | ||
| 8213 | } | ||
| 8214 | } | ||
| 8215 | } | ||
| 8206 | for (auto value : values) { | 8216 | for (auto value : values) { |
| 8217 | if (!_config.reserveComment && ast_is<YueLineComment_t, YueMultilineComment_t, EmptyLine_t>(value)) { | ||
| 8218 | continue; | ||
| 8219 | } | ||
| 8207 | auto item = value; | 8220 | auto item = value; |
| 8208 | switch (item->get_id()) { | 8221 | switch (item->get_id()) { |
| 8209 | case id<VariablePairDef_t>(): { | 8222 | case id<VariablePairDef_t>(): { |
| @@ -8327,7 +8340,7 @@ private: | |||
| 8327 | if (skipComma || temp.back().rfind("--"sv, 0) == 0) { | 8340 | if (skipComma || temp.back().rfind("--"sv, 0) == 0) { |
| 8328 | temp.back() = indent() + temp.back() + nl(value); | 8341 | temp.back() = indent() + temp.back() + nl(value); |
| 8329 | } else { | 8342 | } else { |
| 8330 | temp.back() = indent() + (value == values.back() ? temp.back() : temp.back() + ',') + nl(value); | 8343 | temp.back() = indent() + (value == lastValueNode ? temp.back() : temp.back() + ',') + nl(value); |
| 8331 | } | 8344 | } |
| 8332 | } | 8345 | } |
| 8333 | } | 8346 | } |
