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:
lisettef"You cannot use another ender pearl for {shared.format_duration( remaining, )}."The compiler reports:
text[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
Now let me look at how the formatter tests are set up and find existing f-string format tests:
- Assistant
Now let me add a repro test and run it to confirm current (buggy) behavior:
- Assistant
The repro fit within 80 columns. Let me make it longer to actually trigger the break:
- Assistant
Now implement the fix. First add a source-slice helper to
Comments: - Assistant
Now update
format_stringin the expression formatter: - Assistant
The fix works — the interpolation stays on one line. Now let me add a test for the force-broken fallback path (a
matchinside an interpolation) and verify: - Assistant
Confirmed pre-existing environment failure (no Go toolchain), unrelated to my change. Cleaning up and running the remaining relevant suites:
- Assistant
All checks pass. Let me review the final diff:
- Assistant
Fixed. The formatter no longer splits f-string interpolations across lines, so
lis buildaccepts its output again.Root cause
In
crates/format/src/formatter/expression.rs,format_stringembedded the interpolation expression's document (with all its groups and break points) directly into the f-string. When the line exceeded the 80-column limit, the pretty-printer broke those groups — e.g. splittingshared.format_duration(remaining)into a multi-line call — producing output the lexer rejects (lex.format_string_multiline_interpolation). The bug was reproducible even via the formatter's own idempotency check: formatting its output a second time failed to parse.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.