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
print: bypass the multiline mode of pretty_string_literal for merely trailing \n. (#27)
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"
/>|
0 commit comments