Skip to content

Commit 52ee087

Browse files
committed
fix: #22 - Use a queued indent on the conditional expression test.
1 parent f648e87 commit 52ee087

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/parsing/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,14 +1704,14 @@ fn parse_conditional_expr<'a>(node: &'a CondExpr, context: &mut Context<'a>) ->
17041704
items.push_info(top_most_data.top_most_info);
17051705
}
17061706

1707-
items.extend(parser_helpers::new_line_group(parse_node_with_inner_parse((&node.test).into(), context, {
1707+
items.extend(parser_helpers::new_line_group(with_queued_indent(parse_node_with_inner_parse((&node.test).into(), context, {
17081708
move |mut items, _| {
17091709
if operator_position == OperatorPosition::SameLine {
17101710
items.push_str(" ?");
17111711
}
17121712
items
17131713
}
1714-
})));
1714+
}))));
17151715

17161716
// force re-evaluation of all the conditions below once the end info has been reached
17171717
items.push_condition(conditions::force_reevaluation_once_resolved(context.end_statement_or_member_infos.peek().map(|x| x.clone()).unwrap_or(end_info)));

tests/specs/issues/issue0022.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
~~ deno: true ~~
2-
== should format as-is. This could probably be better and note that the entire assignment is the conditional expression ==
2+
== should format with the test indented. Note the entire assignment is a conditional expr ==
33
const es5Bundle = test === asdf ? true : false ||
44
target === ts.ScriptTarget.ES2016
55
? true
66
: false
77

88
[expect]
99
const es5Bundle = test === asdf ? true : false ||
10-
target === ts.ScriptTarget.ES2016
10+
target === ts.ScriptTarget.ES2016
1111
? true
1212
: false;
1313

14-
== should format as-is ==
14+
== should format with the test indented ==
1515
const es5Bundle = target === ts.ScriptTarget.ES3 ||
1616
target === ts.ScriptTarget.ES5 ||
1717
target === ts.ScriptTarget.ES2015 ||
@@ -21,8 +21,8 @@ const es5Bundle = target === ts.ScriptTarget.ES3 ||
2121

2222
[expect]
2323
const es5Bundle = target === ts.ScriptTarget.ES3 ||
24-
target === ts.ScriptTarget.ES5 ||
25-
target === ts.ScriptTarget.ES2015 ||
26-
target === ts.ScriptTarget.ES2016
24+
target === ts.ScriptTarget.ES5 ||
25+
target === ts.ScriptTarget.ES2015 ||
26+
target === ts.ScriptTarget.ES2016
2727
? true
2828
: false;

0 commit comments

Comments
 (0)