Skip to content

Commit 9699d4f

Browse files
committed
fix: deindent calls (exception)
1 parent 46f0834 commit 9699d4f

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

crates/fmt/src/state/sol.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,13 @@ impl<'ast> State<'_, 'ast> {
846846
&& get_callee_head_size(lhs) + lhs_size <= space_left
847847
{
848848
// Keep complex exprs (where callee fits) inline, as they will have breaks
849-
print_inline(self);
849+
if matches!(lhs.kind, ast::ExprKind::Call(..)) {
850+
self.s.ibox(-self.ind);
851+
print_inline(self);
852+
self.end();
853+
} else {
854+
print_inline(self);
855+
}
850856
} else {
851857
print_with_break(self, false);
852858
}

crates/fmt/testdata/VariableAssignment/bracket-spacing.fmt.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ contract TestContract {
5959
// https://github.com/foundry-rs/foundry/issues/12322
6060
function test_longComplexBinExpr() {
6161
vars.previousTotalDebt = getDescaledAmount(
62-
flow.getSnapshotDebtScaled(streamId),
63-
flow.getTokenDecimals(streamId)
64-
) + vars.previousOngoingDebtScaled;
62+
flow.getSnapshotDebtScaled(streamId),
63+
flow.getTokenDecimals(streamId)
64+
) + vars.previousOngoingDebtScaled;
65+
66+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak
67+
+ vars.previousOngoingDebtScaled;
68+
69+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak()
70+
.previousOngoingDebtScaled();
6571
}
6672
}

crates/fmt/testdata/VariableAssignment/fmt.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ contract TestContract {
5858
// https://github.com/foundry-rs/foundry/issues/12322
5959
function test_longComplexBinExpr() {
6060
vars.previousTotalDebt = getDescaledAmount(
61-
flow.getSnapshotDebtScaled(streamId),
62-
flow.getTokenDecimals(streamId)
63-
) + vars.previousOngoingDebtScaled;
61+
flow.getSnapshotDebtScaled(streamId),
62+
flow.getTokenDecimals(streamId)
63+
) + vars.previousOngoingDebtScaled;
64+
65+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak
66+
+ vars.previousOngoingDebtScaled;
67+
68+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak()
69+
.previousOngoingDebtScaled();
6470
}
6571
}

crates/fmt/testdata/VariableAssignment/original.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ contract TestContract {
4646

4747
// https://github.com/foundry-rs/foundry/issues/12322
4848
function test_longComplexBinExpr() {
49-
vars.previousTotalDebt =
50-
getDescaledAmount(flow.getSnapshotDebtScaled(streamId), flow.getTokenDecimals(streamId))
51-
+ vars.previousOngoingDebtScaled;
49+
vars.previousTotalDebt = getDescaledAmount(flow.getSnapshotDebtScaled(streamId), flow.getTokenDecimals(streamId)) + vars.previousOngoingDebtScaled;
50+
51+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak + vars.previousOngoingDebtScaled;
52+
53+
vars.previousTotalDebt = vars.reallyLongVarThatCausesALineBreak() .previousOngoingDebtScaled();
5254
}
5355
}

0 commit comments

Comments
 (0)