Commit 3256b55
committed
fix: keep a space when densing "-" before a negative operand
denseOperators removed the spaces around a "-" operator even when the
operand that follows it starts with another "-" (a unary minus or a
negative number literal). That glues the two together into "--", which
re-parses as a line comment and silently drops the rest of the line:
format("SELECT 1 - -1 AS x", { denseOperators: true })
=> "SELECT\n 1--1 AS x" // "--1 AS x" is now a comment
Guard against this in the layout: when a token that starts with "-" would
be placed directly after one that ends with "-", keep a single space so the
"--" comment marker can never form. Formatting is idempotent again.1 parent c087896 commit 3256b55
2 files changed
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
| |||
0 commit comments