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:
lisettef"You cannot use another ender pearl for {shared.format_duration( remaining, )}."The compiler reports:
text[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.
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
I'll start by exploring the repository structure.
Assistant
This is a Rust workspace. The issue is about the formatter rewriting f-strings to multiline. Let me look at the format crate.
Assistant
Now let me look at the
format_stringfunction in the formatter.Assistant
I see the issue. In
format_string, the expression inside the interpolation is formatted usingself.expression(e), which can break across multiple lines. Let me look at how the lexer rejects multiline interpolations.Assistant
Let me look at the Document type and how it handles grouping/forcing single line.
Assistant
Let me reproduce the issue first. Let me check how to build and run the formatter.
Assistant
Let me look at the format test snapshots and how formatting tests are structured.
Assistant
Let me find how the formatter is tested and look for format snapshots.
Assistant
Let me look at the test harness and how
assert_format_snapshotworks.Assistant
Now let me look at the
format_sourcefunction and the line width limit.Assistant
Let me build and reproduce. First let me check the CLI format command.
Assistant
Let me write a quick reproduction script. I'll create a temporary test in the format crate.
Assistant
Let me instead add a temporary example binary to the format crate, or use a temporary test. Actually, the format crate is a library. Let me check if I can add an example. Let me create an example in crates/format/examples/repro.rs and run with
cargo run -p format --example repro.But format crate's lib doesn't export
format_source? Let me check lib.rs - yes it exportsformat_sourceviapub fn. Wait, lib.rs haspub fn format_source. Let me check what's exported.Assistant
I've reproduced the issue. Let me see the full first output.
Assistant
I've reproduced the issue. Now let me understand what constructs use
force_breakandGroupin expression formatting, to decide the fix approach.Assistant
Let me look at the call expression formatting.
Assistant
Let me look at the call/invoke formatting which is the most relevant (line ~530-560 and ~840-920). Let me find the call function.
Assistant
Let me look at
join_pattern_entriesand how trailing commas are handled.Assistant
Let me look at
is_inlinable_argand how trailing commas are handled.Assistant
Now I understand the structure. Let me implement the fix by adding a
ForceUnbrokendocument combinator. First, let me edit thelindig.rsdocument engine.Assistant
Now let me make the edits. First, add the
ForceUnbrokenvariant to the enum.Assistant
Now let me add the
ForceUnbrokenvariant to the enum.Assistant
Now add the
force_unbrokenhelper method afterforce_break.Assistant
Now let me add the
ForceUnbrokenhandling in thefitsfunction (afterForceBroken).Assistant
Now let me update the
formatfunction. Let me view the current line numbers.Assistant
Now let me update the
FlexBreakinformatto respectForcedUnbroken.Assistant
The edit got mangled. Let me fix the FlexBreak block by replacing lines 114-134.
Assistant
Now let me update the
Grouparm and add theForceUnbrokenarm informat.Assistant
There's an indentation/brace issue. Let me check lines 216-222.
Assistant
The
matchclosing brace is missing. Let me fix it.Assistant
Now let me update
format_stringinexpression.rsto useforce_unbroken.Assistant
Now let me build and run the reproduction.
Assistant
The interpolations are now single-line. Let me run the existing format tests to make sure nothing breaks.
Assistant
Hmm, no test output. Let me run with --nocapture or check if there are tests in the format crate.
Assistant
Strange, no test output at all. Maybe the format crate has no tests directly, or the output is being suppressed. Let me run with verbose.
Assistant
No tests listed in the format crate? That's odd because sequence.rs had
#[cfg(test)] mod tests. Let me check if there's a problem - maybe the build isn't picking up tests. Wait, the--listreturned nothing. Let me check if maybe the issue is that the example binary still exists and is interfering, or there's a compile issue with tests. Let me run cargo test directly with more verbosity.Assistant
All 25 unit tests pass. Now let me run the format snapshot tests in the
testscrate.Assistant
These failures are in
spec::emit(Go code generation), not format. They may be pre-existing. Let me check by stashing my changes.Assistant
These emit test failures are pre-existing (unrelated to my change — likely a Go version difference in the environment). Let me restore my changes.
Assistant
The stash pop created
.snap.newartifacts. Let me clean those up and run the format-specific tests only.Assistant
Now let me run the format snapshot tests (spec::format) specifically.
Assistant
All 292 format tests pass. Let me test more edge cases with an expanded repro.
Assistant
Excellent! All edge cases produce single-line interpolations, including the nested f-string, lambda args, and the multiline text parts are preserved. Let me run the full test suite to confirm I only have the pre-existing emit failures.
Assistant
Let me check whether any non-emit tests failed (i.e., whether my change introduced new failures outside the pre-existing emit ones).
Assistant
There are also
spec::buildfailures. These likely involve the Go toolchain. Let me verify they're pre-existing by stashing my change and running a couple.Assistant
Confirmed — the
spec::buildandspec::emitfailures are pre-existing (they depend on the Go toolchain/gofmt and fail without my change). My change introduces no new failures, and all 292spec::formattests pass.Let me verify my changes are rustfmt-compliant and clean up.
Assistant
The only fmt diff is in my temporary example file, which I'll delete. Let me confirm the source files are clean, then remove the example.
Assistant
Source files are fmt-clean. Let me do a final clippy/build check on the format crate for warnings.
Assistant
No warnings. Let me run the format tests one final time to confirm everything passes after cleanup.
Assistant
All tests pass. Let me review the final diff.
Assistant
I notice I accidentally removed a blank line before the
Grouparm. Let me restore it for a minimal diff.Assistant
The blank line between the
NestIfBrokenandGrouparms was removed. Let me restore it.Assistant
Now let me rebuild and rerun the format tests to confirm everything still works after the whitespace restoration.
Assistant
Let me do a final review of the complete diff and ensure no stray files remain.
Assistant
The diff is clean and minimal. Let me do a final end-to-end verification with the exact issue example.
Assistant
Verified. Let me confirm no stray files remain and the example directory is gone.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.