Commit e8757ad
authored
At some point I added a multiline pretty string format using
Rust-compatible string continuations, i.e. `\` at the end of a line
ignores all whitespace following it, so these are equivalent Rust
literals:
```rust
"foo\
\n"
```
```rust
"foo\n"
```
```rust
"foo
"
```
(the last one is never used by `spirt::pretty`, because it cannot be
indented without changing the meaning of the string literal, and
`spirt::print::pretty` assumes *everything* can be indented)
This PR ignores trailing `\n` when determining whether the multiline
format should be used, i.e. only `\n` *in the middle* of a string will
use `\` continuations (with the `\n` moved to the start of following
lines).
---
Quick example (the very one that made me think it'd be worth a minor
aesthetic improvement):
|Before|After|
|-|-|
|<img width="1276" height="1127" alt="image"
src="https://github.com/user-attachments/assets/7f6bdb20-79ff-4f25-b2f9-e9b961578bac"
/>|<img width="2066" height="566" alt="image"
src="https://github.com/user-attachments/assets/afca8cba-0d00-45fd-ba66-bbd059238a88"
/>|
1 file changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1723 | 1723 | | |
1724 | 1724 | | |
1725 | 1725 | | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
1726 | 1730 | | |
1727 | 1731 | | |
1728 | 1732 | | |
1729 | 1733 | | |
1730 | 1734 | | |
1731 | | - | |
| 1735 | + | |
1732 | 1736 | | |
1733 | 1737 | | |
1734 | 1738 | | |
| |||
1747 | 1751 | | |
1748 | 1752 | | |
1749 | 1753 | | |
1750 | | - | |
| 1754 | + | |
| 1755 | + | |
1751 | 1756 | | |
1752 | 1757 | | |
1753 | 1758 | | |
| |||
0 commit comments