ISSUE DESCRIPTION Formatter rewrites Lisette f-strings to multiline interpolation that…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
Assistant
Now let's look at the top of expression.rs for imports and constants used.
Assistant
Now let's implement the fix in
format_string.Assistant
Now let's add the constant
FSTRING_INTERPOLATION_WIDTHand ensure imports work.Assistant
Now build to check compile.
Assistant
Compiles. Now let's write a reproduction script to test the exact scenario from the issue.
Assistant
Let's make it exceed 80 chars to trigger wrapping, using the exact issue example but as valid single-line source first.
Assistant
Confirmed the bug is reproduced without the fix (formatter breaks the line, producing invalid multi-line interpolation). Now let's verify with the fix applied.
Assistant
The fix works — the interpolation stays on a single line, exceeding 80 chars if necessary rather than wrapping. Let's test a few more edge cases: nested f-strings, multiple interpolations, long chains, and format-idempotency (re-format should be stable).
Assistant
Spread syntax is
xs...not...xs. Let me fix that test case.Assistant
All edge cases work correctly and idempotently. Now let's clean up temp example files and run the full test suite.
Assistant
Good — these same 11 failures exist on the unmodified repo (likely due to missing
gofmtin this environment), confirming they're pre-existing and unrelated to my change. Let's clean up the.snap.newfiles and run the format-specific test module only.Assistant
Now let's run the actual format-focused test suite (
tests/spec/format) specifically, and the lex/parse ones related to f-strings.Assistant
All 292 formatter tests pass. Let's also run lex/parse/desugar tests that mention format strings, plus the fuzz seed corpus test if any, and the full test suite excluding the known-broken emit ones for sanity (just to be thorough, diff counts before/after).
Assistant
Confirmed identical pre-existing failure count (1588 failed both before and after) — same set of emit/build tests, unrelated to gofmt/env issues, not caused by my change. Let's clean up all the generated
.snap.newfiles.Assistant
Clean. Now let's check the earlier
.newsnapshot for spec::emit::expressions module more specifically to make sure those failures are truly pre-existing (already confirmed by identical count) and unrelated to format string content changes (just gofmt formatting differences likefunc noop() {}->func noop () {}).Assistant
No such edge cases in the test suite. Let's check the
format_fstring_multiline_text_roundtrip.snaptest to confirm it doesn't involve interpolation expressions across lines.Assistant
As expected, this already fails at parse/lex level regardless of formatter — confirming the edge case is a pre-existing language restriction, not something my formatter fix needs to handle. Let's clean up.
Assistant
Now let's run the full formatter test suite once more, plus check
cargo fmt/clippy conventions if used in this repo.Assistant
Let's fix the import ordering to match rustfmt conventions.
Assistant
Good,
cargo fmtreports clean now. Let's run the full build and tests one final time to confirm everything is in order.Assistant
Full workspace builds cleanly. Let's do a final check of the diff and git status.
Assistant
This is a minimal, focused fix. Let me go through the checklist:
Assistant
Same 1588 pre-existing failures (all due to missing
gofmtin this environment, confirmed earlier to be identical before/after my change). Let's clean up any generated.snap.newartifacts.Assistant
Now let me review the checklist explicitly as requested.
Checklist review:
-
[x] If an error was reported in the issue description, I have successfully reproduced it. I wrote a throwaway example (
crates/format/examples/repro.rs) usinglisette_format::format_sourcewith a single-line f-string interpolation call () that exceeds the 80-column width limit. Before my fix, the formatter split the call arguments across multiple lines inside the interpolation — exactly the bug described in the issue (confirmed via / to compare before/after).
-
Assistant
Clean. Only the intended two-file diff remains.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.