Skip to content
Snippets Groups Projects
Commit 4388b2bf authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1895358 - Part 1: Improve formatting of long multiline argument lists, r=ipc-reviewers,mccr8

This changes the way that StmtCode handles the pattern `$,{list}` alone on a
line, adjusting it such that each item on the list is printed onto its own
line, and then indented. This helps the formatting of large lists such as the
ones generated in part 2.

Differential Revision: https://phabricator.services.mozilla.com/D209854
parent 106fb204
No related branches found
No related tags found
No related merge requests found
......@@ -153,9 +153,18 @@ def _line(raw, skip_indent, lineno, context):
inline = match.span() != (0, len(line))
for idx, value in enumerate(values):
# When using `,` as a list mode in a non-inline environment, put
# each expression on its own line.
multiline_list = list_chr == "," and not inline
# If we're using ',' as list mode, put a comma between each node.
if idx > 0 and list_chr == ",":
children.append(VerbatimNode(", "))
children.append(VerbatimNode(",\n" if multiline_list else ", "))
# Expr entries such as those used in multiline lists do not indent,
# so add a node to handle indenting on each line.
if multiline_list:
children.append(VerbatimNode("", indent=True))
# If our value isn't a node, turn it into one. Verbatim should be
# inline unless indent isn't being skipped, and the match isn't
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment