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 locate the Lisette formatter and how f-string interpolation is handled.
- Assistant
The format crate looks central — I'll inspect how it formats f-string interpolations.
- Assistant
rg is not available, let me use grep.
- Assistant
Let me look at the format_string function in expression.rs.
- Assistant
I need to understand Document and how line-breaking is controlled so interpolations can stay single-line.
- Assistant
Let me look at next_break_fits and how other single-line constraints are handled. Also need to look at how calls are formatted since the example is a function call that gets split.
- Assistant
I'll inspect the pretty-printer logic and any format tests that cover f-strings.
- Assistant
There's ForcedUnbroken mode — I'll read how formatting applies it during pretty-printing.
- Assistant
Let me read the rest of format related to Group and NextBreakFits
- Assistant
I'll check git history and how Gleam-style formatters keep interpolations single-line.
- Assistant
Looking at format() again for NextBreakFits:
- Assistant
Continue reading format_call_with_head
- Assistant
This looks Gleam-like — I'll compare with how their pretty printer treats ForcedUnbroken and format strings.
- Assistant
I need to check what the compiler allows inside f-string interpolations.
- Assistant
Let me look at the lexer/parser where multi-line interpolation is rejected.
- Assistant
Let me look at the lexer code around format string interpolation.
- Assistant
So multiline interpolations are rejected at lex time. The formatter must not produce them. I see the core problem: the formatter is turning valid single-line f-string interpolations into multi-line ones that the compiler rejects. The simplest fix is to make the formatter respect the single-line constraint for f-string interpolations.
Let me think about the best approach.
- Assistant
Let me look at format tests.
- Assistant
There are format tests. Let me search for format_string related format tests.
- Assistant
Looking at Goulden format_string and format_string_multiline_roundtrip tests:
- Assistant
Let me look at the multiline format string test and line_breaking_long_call_args.
- Assistant
I'll reproduce the bug with a small formatter script first.
- Assistant
I'll write a small temporary program to reproduce the issue.
- Assistant
Need to set up rust toolchain.
- Assistant
It seems to be installing. Let me wait and try cargo again from 0 the lisette directory.
- Assistant
Case 3 reproduces it. Unlimited-width rendering of interpolations may work for calls; I'll verify how comments interact and compare with a proper ForcedUnbroken approach.
- Assistant
I'll check whether blocks can appear inappell f-string interpolations and review appending newline handling.
- Assistant
I'll check how blocks handle single-line cases and what the intended format is.
- Assistant
I'll implement a
ForceUnbrokendocument mode so f-string interpolations stay single-line, including nested groups and newlines. - Assistant
Implementing ForceUnbroken in the pretty-printer and applying它 to f-string interpolations.
- Assistant
Now update the format function.
- Assistant
Updating FlexBreak، Newline, Group, and adding ForceUnbroken handling.
- Assistant
Now update the Document enum and add force_unbroken method.
- Assistant
The enum definition looks corrupted — I'll inspect and fix the file structure.
- Assistant
Restoring the broken Document enum declaration.
- Assistant
Adding the force_unbroken method next to force_break.
- Assistant
Now update format_string to use force_unbroken.
- Assistant
Update format_string to force_unbroken on expressions.
- Assistant
Re-running the repro case and checking blocks.
- Assistant
f"x {{ a }}"might mean escaped braces — verifying how that's parsed. - Assistant
Interesting -
f"x {{ a }}"andf"x { { a } }"format to the same thing. Let me check if{{is a block expressionor escaped braces. Looking at the lexer for format strings. - Assistant
Blocks in f-strings were already mishandled; focusing on the reported call-splitting issue. Running format tests next.
- Assistant
Some format tests failed — comparing our lindig.rs with the original.
- Assistant
Checking whether emit failures are related or just flaky:
- Assistant
Emit failures look like missing gofmt, not our changes. Digging into the method chain format failure next.
- Assistant
Checking lambda formatting and what else might affect method-chain fitting.
- Assistant
Let me look at lambda function
- Assistant
Reproducing the method-chain formatting abnormality in isolation:
- Assistant
Typo with cyrillic characters accidentally.
- Assistant
I'm making typos. Let me be more careful.
- Assistant
The fits() change for ForceBroken under ForcedUnbroken broke
next_break_fits(false)— reversing that part. - Assistant
Checking pipeline formatting for bare Newlines:
- Assistant
Re-testing after the revert:
- Assistant
Method chains تwork again and the f-string fix still holds. Running the format tests again.
- Assistant
Checking whether the Newline-in-fits change under ForcedUnbroken alters call formatting with pipelines:
- Assistant
Checking whether stash pop restored cleanly and if outputs match.
- Assistant
Cleaning up temp emit snapshot files and doing a final verification.
- Assistant
Reviewing the final diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.