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
Let me look at how the parser/lexer handles f-string interpolations to know which expressions can appear inside.
- Assistant
Now let me look at the format crate tests to understand testing conventions.
- Assistant
Now add tests. Let me check the snapshot test macro first:
- Assistant
Now add tests near the existing f-string tests:
- Assistant
All three snapshots show the desired behavior: interpolations stay single-line, and when a line is too long the surrounding call breaks at argument boundaries instead of inside the string. Now run the full test suite to check for regressions:
- Assistant
Many failures — let me check whether they're pre-existing (e.g., environment-related) by inspecting one:
- Assistant
Now run the full suite and check that all failures are confined to the Go-dependent categories:
- Assistant
Clippy is clean. Let me do an end-to-end sanity check with the actual CLI on the reported example:
- Assistant
Reproduced the exact bug from the report with the old code, and verified the fix resolves it. Done.
Summary
Root cause: In
crates/format/src/formatter/expression.rs,format_string()embedded interpolation expressions as regular breakable documents. When a line exceeded the 80-column limit, the pretty-printer broke groups inside the interpolation (e.g. splitting call arguments across lines), producing multilinef"{...}"interpolations that the lexer rejects withformat_string_multiline_interpolation.Fix:
crates/format/src/lindig.rs— addedDocument::flatten(), which recursively replaces everyStrictBreak/FlexBreakwith its unbroken text so the document renders on one line regardless of the width limit (inherently multi-line content like verbatim text is preserved).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.