Formatter rewrites Lisette f-strings to multiline interpolation that the compiler…
- User
Formatter rewrites Lisette f-strings to multiline interpolation that the compiler rejects
lis buildrejects multiline interpolation expressions insidef"...{...}"strings, but Zed’s Lisette formatter appears to rewrite single-line calls across lines automatically.Example:
f"You cannot use another ender pearl for {shared.format_duration( remaining, )}."The compiler reports:
[error] Multi-line f-string interpolation ... error: f-string interpolations must be single-lineImpact:
lis buildfails after formatting in touched spots.- This forces manual one-line edits to pass build.
Expected:
- Either Lisette formatter should preserve single-line interpolation in compatible cases, or
- Formatter rules should be configured to avoid splitting interpolation argument expressions across lines.
Interface
No new interfaces are introduced.
- Assistant
It didn't split there. Let me try deeper nesting closer to the report:
- Assistant
Reproduced exactly. Now let me check how block expressions render, since
ifexpressions can appear inside interpolations: - Assistant
All edge cases hold. Now add regression tests and run the suite:
- Assistant
292 existing tests pass; the 3 new ones just need their snapshots created. Let me accept them and review:
- Assistant
All 295 format tests pass. Now run the broader test suite to make sure nothing else regressed (LSP formatting, e2e, etc.):
- Assistant
Now run the suites that don't depend on the Go toolchain — format, lex, parse, desugar — plus the format crate's unit tests and clippy:
- Assistant
The multi-filter invocation only ran 31 tests — rerun with filters passed properly:
- Assistant
All 805 pass. Final end-to-end check with the actual CLI
fmtcommand: - Assistant
The only error is my test program's use of
println— no f-string diagnostic. The fix works end-to-end through the CLI. Clean up and review the final diff: - Assistant
Fixed. The formatter no longer rewrites f-string interpolations across multiple lines.
Root cause
In
crates/format/src/formatter/expression.rs:239,format_stringembedded each interpolation expression's layout document directly into the f-string document. When the line exceeded the 80-column limit, the pretty-printer broke the expression's internal groups (call arguments, binary chains), producing output like:f"...for {shared.format_duration( remaining, )}."— which the lexer categorically rejects (
error_multiline_format_string_interpolation,crates/syntax/src/lex/errors.rs:227). Since the lexer guarantees interpolations are single-line in any parseable source, the formatter must never introduce breaks there.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.