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 what we're working with.
Assistant
This is a Rust repository. Let me explore the crates directory.
Assistant
There's a
formatcrate. Let me look at it.Assistant
Now let me look at the
Documenttype and howexpressionworks to understand how things break across lines.Assistant
Let me look at the full Document rendering and the printer logic.
Assistant
Let me look at the expression formatting, especially calls, to understand what produces multiline output.
Assistant
Let me reproduce the issue. First, let me find how to run the formatter.
Assistant
Let me look at the format crate's tests and lib.
Assistant
Now let me look at the tests for the format crate, to understand how they're tested. The lib says
test = false. Let me find where format tests live.Assistant
Let me find format snapshot tests.
Assistant
Let me find the
assert_format_snapshot!macro and existing f-string tests.Assistant
Let me look at the assert_format_snapshot! macro definition.
Assistant
Let me build the format crate first to ensure things compile, and write a reproduction. Let me check the workspace.
Assistant
Let me create a reproduction example in the format crate.
Assistant
The crate name is
lisette-formatbut the lib name is... let me check. The Cargo.toml hasname = "lisette-format". The package name with a dash becomes a hyphenated crate. To reference, I should uselisette_format. Let me check the lib name. The lib.rs is atcrates/format/src/lib.rs. There's no[lib] nameso the lib name islisette_format(dash -> underscore). Let me uselisette_format.Assistant
I've reproduced the issue. The formatter splits the f-string interpolation across lines, and the result is not idempotent (second format fails to parse). Let me examine how the document model handles "flat" forcing.
Assistant
Let me look at the call formatting code to understand
next_break_fitsusage.Assistant
Let me look at the full lindig.rs and check
flex_break/strict_breakusage.Assistant
flex_breakis imported in expression.rs but let me check if it's actually used.Assistant
Let me look at the binary_operator to understand flex_break usage.
Assistant
Let me look at the
let_andreturn_formatting to understand the surrounding context of the f-string.Assistant
Now let me check for any other exhaustive matches on the
Documentenum besidesfitsandformat.Assistant
Let me look at the rest of the
impl Document(append, concat, Documentable) to verify no exhaustive matches.Assistant
I now have a clear understanding. The fix requires adding a "force flat" document variant so f-string interpolations always render on a single line. Let me implement it. First, the
Documentenum and helper method.Assistant
Now let me add the
Flatvariant and helper method:Assistant
Let me navigate to line 211 and apply the edit.
Assistant
Now add the
flat()helper method:Assistant
Now let me handle
Flatin thefitsfunction. Let me viewit.Assistant
Now add the
Flatcase to thefitsfunction:Assistant
Now let me handle
Flatin theformatfunction and makeGroup/FlexBreakrespectForcedUnbroken. Let me view the format function.Assistant
Now let me modify the
formatfunction. First, theGroupcase to respectForcedUnbroken:Assistant
Now modify
FlexBreakinformatto respectForcedUnbroken:Assistant
Now update
format_stringin expression.rs to wrap the interpolation expression in.flat():Assistant
Now let me run the reproduction to confirm the fix:
Assistant
The fix works — the interpolation stays on a single line, and idempotency holds. Let me test more edge cases.
Assistant
All edge cases work correctly. Now let me run the existing format test suite to ensure nothing is broken.
Assistant
Let me run the format spec tests:
Assistant
There are failures in emit tests, which is unexpected since I only touched the formatter. Let me check whether these are pre-existing by stashing my changes.
Assistant
The failure is pre-existing (happens without my changes). It seems related to
gofmtnot being available. Let me check.Assistant
Go isn't installed, so those emit failures are environmental and pre-existing. The test run created
.snap.newartifacts — let me remove them.Assistant
Now let me run only the
spec::formattests (which don't need Go):Assistant
All 292 format spec tests pass. Let me also run the workspace unit tests (lib/bins) to be thorough:
Assistant
Let me check whether the Zed editor has a separate formatter implementation that might also need fixing.
Assistant
No formatter in Zed's source. The Zed extension likely uses the
lisCLIformatcommand (theformatcrate). Let me check the extension.toml to confirm.Assistant
Let me confirm the LSP and CLI formatting handlers use
format_source(the path I fixed):Assistant
Both CLI and LSP use
format_source, so the fix covers all formatter entry points. Let me test a few more edge cases including pipelines and slices inside f-strings.Assistant
All edge cases work correctly, including multiline-text f-strings where the interpolation still stays single-line. Let me clean up the temporary example files.
Assistant
Let me review the complete diff to verify the changes are correct.
Assistant
The diff is clean. Let me verify the dependent crates (CLI, LSP) still compile, since they use the formatter.
Assistant
Both CLI and LSP compile. Let me run the format tests once more as a final confirmation, along with the format unit tests.
Assistant
All tests pass. Let me do a final build check to confirm no warnings were introduced.
Assistant
No warnings. Let me confirm the final repository state is clean (only the intended source changes, no stray artifacts).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.