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
Fix works. Remove the scratch example and add regression tests:
- Assistant
Now run the full test suite to check for regressions elsewhere:
- Assistant
Many emit tests failing — let me check whether that's pre-existing on a clean tree:
- Assistant
All checks pass. Summary of the fix:
Problem
The formatter rendered f-string interpolation expressions as regular documents, so when a line exceeded the 80-column limit, the pretty-printer would split the interpolated expression (e.g. call arguments) across lines — producing output the compiler rejects, since f-string interpolations must be single-line (
crates/syntax/src/lex/errors.rs:232).Fix
crates/format/src/formatter/expression.rs— informat_string, interpolation expressions are now pre-rendered flat with an unbounded line width (isize::MAX), so no group inside an interpolation can ever break:FormatStringPart::Expression(e) => { // The compiler rejects multi-line f-string interpolations, // so render the expression flat regardless of line width. let expression = self.expression(e).to_pretty_string(isize::MAX); docs.push(Document::str("{")); docs.push(Document::string(expression)); docs.push(Document::str("}")); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.