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
I'll start by exploring the repository structure to understand the codebase and find the relevant files.
Assistant
I need to make single tool calls. Let me explore the repository structure.
Assistant
There's a
formatcrate. Let me explore it.Assistant
Let me search the syntax crate for f-string parsing.
Assistant
Now let me look at how the formatter handles f-strings. Let me search for the relevant syntax nodes.
Assistant
Now let me look at how the formatter handles FormatString. Let me search the format crate.
Assistant
Now I found the relevant code. Let me look at the
Documenttype and howexpressionworks.Assistant
Let me look at the
expressionmethod and how calls are formatted.Assistant
Let me find how to run the formatter via the CLI.
Assistant
Now let me look at
format_sourcein the format crate.Assistant
Let me build the project and reproduce the issue. First, let me check the build setup.
Assistant
The build succeeded. Now let me reproduce the issue.
Assistant
Interesting, the trailing comma case didn't break. Let me create a longer line to trigger the multiline split, matching the issue's example.
Assistant
That still kept the f-string on one line because the f-string itself is within the line width once the
println(breaks. Let me make the f-string content itself too long to fit on one line even after the println break.Assistant
I've reproduced the issue. The formatter splits the f-string interpolation expression across multiple lines. Let me verify the compiler rejects this.
Assistant
Let me re-read the full lindig.rs to understand the document model thoroughly.
Assistant
Let me look at where
flex_break,force_break, andnext_break_fitsare used in the formatter to understand the break model.Assistant
Let me look at existing formatter tests to understand the test setup.
Assistant
Let me look at the format test mod.rs to understand the test structure.
Assistant
Let me look at the test harness macro.
Assistant
Let me find existing f-string tests in the format mod.rs.
Assistant
Let me look at
format_call_with_headfully to understand the break behavior of calls.Assistant
Now I understand the issue and the document model. The fix requires:
- Adding a way to force an expression to render "flat" (single-line) in the document engine.
- Using it for f-string interpolation expressions.
Let me first look at the exact
format_stringand confirm my understanding, then implement. Let me check howMode::ForcedUnbrokeninteracts — currentlyGroupinformatre-evaluatesfitsregardless of parent mode, which is the root cause. Let me implement the fix in lindig.rs.Assistant
Now let me implement the fix. First, add the
Flatvariant to theDocumentenum.Assistant
Now let me add the
Flathandling in thefitsfunction and modify theformatfunction'sGroupandFlexBreakhandlers.Assistant
Now let me update
format_stringin expression.rs to wrap the interpolation expression inflat.Assistant
Now let me build to verify it compiles.
Assistant
Now let me re-test the reproduction cases.
Assistant
The interpolation now stays single-line. Let me verify the formatted output is now valid (re-lexes/parses) by running format again (idempotency) and checking the compiler accepts it.
Assistant
Let me test the exact example from the issue and confirm the formatter no longer produces multiline interpolation.
Assistant
Let me test edge cases and run the existing format test suite.
Assistant
All edge cases work. Now let me run the existing format test suite to ensure nothing breaks.
Assistant
These failures are in
spec::emit(Go code generation), notspec::format. They look environment-related (Go toolchain). Let me verify whether they fail without my changes by stashing.Assistant
These emit failures are pre-existing (environment-related, fail without my changes). Let me restore my changes.
Assistant
The stash pop left
.snap.newartifacts from the failed tests. Let me clean those up.Assistant
Now let me run only the
spec::formattests to confirm my changes don't break the format suite.Assistant
All 292 format tests pass. Let me run the full suite to confirm only the pre-existing emit failures remain (and clean up any
.snap.newartifacts).Assistant
The 1588 failures are all
spec::emit(Go codegen, environment-related). Let me confirm there are zero non-emit failures and clean up artifacts.Assistant
There are also
spec::buildfailures (Go toolchain). Let me verify these are also pre-existing by stashing my changes.Assistant
Confirmed: identical failures (1588 failed) occur without my changes — all pre-existing/environmental (Go toolchain). My changes introduce no new failures. Let me clean up the
.snap.newartifacts.Assistant
Let me also run the lex and parse spec tests to ensure my changes (which only touch the format crate) don't affect them, and check the format crate's own tests.
Assistant
Let me also verify the lint and other spec tests pass (excluding the environmental emit/build ones).
Assistant
Let me check a potential edge case: block expressions inside f-string interpolations.
Assistant
Let me test a block expression inside an f-string interpolation to ensure no panic/crash.
Assistant
Let me confirm the block-in-interpolation case is unchanged (no regression) by comparing with stashed changes.
Assistant
No regression — block behavior is identical. Now let me clean up temp files and review my final diff.
Assistant
The diff is clean. Let me test a couple more edge cases: nested f-strings and an f-string whose interpolation itself contains a string with escapes.
Assistant
All edge cases pass. Let me do a final clean build and run the format suite once more to confirm everything is good.
Assistant
Let me clean up any stray snapshot artifacts and confirm the final git status.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.