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 and locating the formatter code that handles f-string interpolation.
- Assistant
Looking at the formatter's string/expression handling and any tests related to f-strings.
- Assistant
Let me search for relevant code about format strings and multiline interpolation.
- Assistant
Inspecting how the formatter currently formats f-string interpolations:
- Assistant
Checking how Document force_break / flat works and how calls are formatted:
- Assistant
I need to understand ForcedUnbroken mode better and how force_unbroken works on Document.
- Assistant
There's no force_unbroken method yet maybe. Let me read more of the Document API and how rendering works, and also look at similar cases where expressions are forced to single line.
- Assistant
Looking at the pretty printer more carefully - I need to understand Mode::ForcedUnbroken. Let me read the full format function.
- Assistant
Let me see how groups work when choosing broken/unbroken mode:
- Assistant
Inspecting call formatting and related patterns:
- Assistant
Checking the changelog and git history for related f-string formatting fixes:
- Assistant
Reproducing the formatter issue with a quick script:
- Assistant
Let me create a quick reproduce using cargo test or a small rust program. Looking at how tests work.
- Assistant
I'll write a small rustc/Cargo example to reproduce. Or I can use cargo test with a temporary binary. Actually easiest is to use the format crate directly.
- Assistant
I'll add a temporary unit test to reproduce. Actually the instructions say not to add tests to the repository. I can create a temporary script outside.
- Assistant
Let me check the CLI package name.
- Assistant
Package name is lisette
- Assistant
Good, now let me reproduce with the format command.
- Assistant
Let me see the formatted file
- Assistant
Confirming reproduction. Checking Gleam-style patterns and implementing
force_unbrokenfor f-string interpolations. - Assistant
Checking how trailing commas behave when unbroken:
- Assistant
Implementing
ForceUnbrokenin the pretty-printer and using it for f-string interpolations. - Assistant
Now update the format function for FlexBreak, Group, and ForceUnbroken.
- Assistant
Need to navigate to the right place first with the open file window.
- Assistant
Now I can replace the FlexBreak and Group handling.
- Assistant
Now update Group handling and ForceBroken | NextBreakFits to include ForceUnbroken
- Assistant
I need to update Group, ForceBroken handling, enum, and add force_unbroken method.
- Assistant
Add force_unbroken method after force_break
- Assistant
Now update format_string to use force_unbroken on expressions.
- Assistant
Rebuilding and verifying the fix against the reproduction cases:
- Assistant
Good, compiled. Now reproduce.
- Assistant
Main cases fixed. Running format tests and checking methods chains inside interpolations:
- Assistant
Pipeline still breaks — investigating its formatting and running the format-only tests:
- Assistant
Format tests all pass. Pipeline inside f-string still breaks — looking into that next.
- Assistant
Hard
Newlinebreaks force-unbroken; checking method chains and flattening newlines under that mode. - Assistant
Flattening hard newlines when in ForcedUnbroken mode so pipelines and similar stay single-line.
- Assistant
Need to Floors update format()'s Newline handling. Note thatpending_indent: when we flatten newline to space, we should prom apply pending_indent if any, thendepart space.
- Assistant
Need to goto line 114.
- Assistant
Now replace
- Assistant
Rebuilding and retesting all cases, including pipelines:
- Assistant
There's a typo in my cargo test command. Let me fix and run tests properly. Also note booking my "block" test was raw string text
{{which is escaped braces not a act block expression. - Assistant
Testing block expression formatting inside f-strings:
- Assistant
My commands got mangled. Let me be more careful.
- Assistant
There's something weird with howera unicode is being introduced. Let me use_simple paths.
- Assistant
I'm making typos. Letmesimpli.
- Assistant
Improving
fitsfor ForceBroken under ForcedUnbroken so width of flattened content is measured correctly: - Assistant
Need to goto baby that linen.
- Assistant
Now replace
- Assistant
Checking for other exhaustive matches on the Document enum:
- Assistant
Running format tests and reviewing the final diff:
- Assistant
Three snapshot tests failed — investigating whether our Change caused them:
- Assistant
Typo in filter again.
- Assistant
Reverting the ForceBroken+ForcedUnbroken fits change — it broke
next_break_fits(false)comment handling. - Assistant
Checking whether the failed tests still fail after the ForceBroken revert — the Newline-in-fits change may still affect
next_break_fits(false): - Assistant
All format tests pass. Checking for regressions on pipelines as call arguments:
- Assistant
Comparing pipeline-as-arg formatting against the original code:
- Assistant
Using a separate
Flatmode so we don't changeForcedUnbrokensemantics used bynext_break_fits: - Assistant
Implementing a dedicated
Flatmode for force_unbroken, without changingForcedUnbrokenbehavior: - Assistant
Now update all the match arms to use Flat properly.
- Assistant
Now update format() function similarly.
- Assistant
I need to update Newline, FlexBreak, StrictBreak, Group, and ForceUnbroken in format().
- Assistant
Now update Group and ForceUnbroken in format().
- Assistant
Update Group to handle Flat and ForceUnbroken to use Flat.
- Assistant
Cleaning up leftover snapshot files and retesting:
- Assistant
All 292 format tests pass. Verifying the output properly:
- Assistant
Doing a final review of the complete lindig changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.