You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d3df6d5
Browse filesBrowse the repository at this point in the historyBrowse files
fix(format): keep the extra indent of a tighter operator under a looser one
A line inside a group led by an operator of another tier, such as + c, kept the group's
indentation when it broke again, so * d lined up under + c and read as (... + c) * d. Such a
line now keeps the usual extra indent. A subquery's clauses and a window's PARTITION BY are no
longer taken for a group's only operand. VALUES row openers are looked up in a mask instead of
a list, so a long VALUES list no longer slows the layout down quadratically.
The first commit also stops a long line from breaking before AND, OR or an arithmetic operator
that sits between a CASE and its END on that line.
Copy file name to clipboardExpand all lines: crates/sqlquack-format/src/format/_helpers/printed_layout.rs
+24-17Lines changed: 24 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -457,14 +457,15 @@ impl PrintedSql<'_> {
457
457
458
458
/// Start the inside of each parenthesised group that spans lines on its own line and close it on its own line, so a group never opens or closes on the line of another; true when a gap changed.
/// Apply the outermost applicable break: chains, VALUES rows, bracket groups, then commas.
953
+
/// Apply the outermost applicable break: chains, VALUES rows, bracket groups, then commas; an operator in a group's only operand takes the group's indentation unless the line starts with another tier's operator, so `+ c` then `* d` cannot read as `(… + c) * d`.
953
954
fnbreak_line(&mutself,line:&Line) -> bool{
954
955
let values_row = self.tokens[line.first] == OPEN_PARENTHESIS && self.locked[line.first + 1];
/// Whether `line` starts or continues with an operator the one operand of a parenthesised group whose inside starts on its own line, so an operator broken onto a new line cannot read as the start of another item.
972
+
/// Whether `line` starts or continues with an operator the one operand of a parenthesised group whose inside starts on its own line, so an operator broken onto a new line cannot read as the start of another item. A subquery's clauses and a window's PARTITION BY are never one operand.
0 commit comments