Commit bb5edc4
fix: make retrieve inter-clause whitespace robust to indent changes
Replaces the hard-coded "\n " / "\r\n " suffix matches with a
backwards walk that strips a trailing newline plus whatever indent
(spaces or tabs) follows it. The formatter re-emits its own indent
before each clause, so the original source's trailing newline+indent
is structural and would duplicate after a roundtrip — but the old
4-space match silently dropped the entire whitespace gap if the
formatter or the source used a different width. Adds a doc comment
explaining the contract.
Also documents the `not(` heuristic in shouldPreserveExpressionSource
so future readers know it preserves the compact form against the
parser's `not (<expr>)` re-emission.
Addresses ako's review on PR #323.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent c643c3f commit bb5edc4
1 file changed
Lines changed: 34 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1045 | 1056 | | |
1046 | 1057 | | |
1047 | 1058 | | |
1048 | 1059 | | |
1049 | | - | |
1050 | | - | |
1051 | | - | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
1052 | 1075 | | |
| 1076 | + | |
1053 | 1077 | | |
1054 | 1078 | | |
1055 | 1079 | | |
| |||
1227 | 1251 | | |
1228 | 1252 | | |
1229 | 1253 | | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
1230 | 1261 | | |
1231 | 1262 | | |
1232 | 1263 | | |
| |||
0 commit comments