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
Investigating how the Lisette formatter handles f-string interpolation so we can prevent multiline rewrites the compiler rejects.
- Assistant
Adding
ForceUnbrokento the formatter so f-string interpolations stay single-line, then writing a test for the reported case. - Assistant
Implementing
ForceUnbrokenand applying it to f-string interpolations. - Assistant
Groupwas re-probing withUnbrokenand could still chooseBrokeninsideForceUnbrokeninterpolations. UpdatingGroupto respectForcedUnbrokenmode. - Assistant
Tests pass functionally; accepting snapshots and running the full format test suite.
- Assistant
Fixed. The Lisette formatter was breaking call expressions inside f-string
{...}interpolations because nestedGroupnodes still chose a broken layout even when the line was too long. The compiler requires those interpolations to stay on a single line.Cause
format_stringformatted interpolation expressions with the normalexpression()path, which can wrap calls across lines.next_break_fits(false)alone wasn’t enough — innerGroupnodes would still break when content exceeded the 80-column limit.Fix
ForceUnbrokendocument variant (crates/format/src/lindig.rs) — a layout mode that keeps content on one line, similar to the existingForceBroken.GrouprespectsForcedUnbroken— when inside a forced-unbroken region, groups no longer switch to broken layout.- F-string interpolations use
force_unbroken()(crates/format/src/formatter/expression.rs) — expressions inside{...}are formatted without line breaks.
Your example now stays:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.