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.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /lisette, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and understanding how the Lisette formatter handles f-strings.
- Assistant
Let me look at the crates and find formatter-related code.
- Assistant
There's a format crate. Let me explore it.
- Assistant
Let me search for f-string related formatting code.
- Assistant
Let me look at the formatter expression code for format strings.
- Assistant
Let me read the format_string function in detail.
- Assistant
I need to understand how Document formatting and line-breaking works.
- Assistant
Let me look at the Document enum and how things work. Also let me look at format tests.
- Assistant
Looking at the format algorithm, when Mode::Unbroken is used for the top-level call, groups can still break if they don't fit. The issue is that expressions inside f-strings get formatted with breaks....
- Assistant
There's a Mode::ForcedUnbroken which seems designed for this. Let me see how next_break_fits is used.
- Assistant
Looking at call formatting around line 662-720 to understand the pattern.
- Assistant
I also notice that Document::Newline always produces a newline, even in ForcedUnbroken mode! That's a problem for blocks. Let me check ForcedUnbroken usage in group.
- Assistant
Let me check git history and any related comments about this issue.
- Assistant
Let me look at format string formatting tests and reproduce the issue.
- Assistant
Let me read the format_string tests and the assert_format_snapshot macro, and try to reproduce.
- Assistant
Let me try to reproduce the issue with a quick test program.
- Assistant
I'll write a quick reproduction script using the format crate.
- Assistant
The package is named lisette-format but the lib is probably named format. Let me check.
- Assistant
Need to set up the rust toolchain.
- Assistant
Good, toolchain is being installed. Let me try running the repro from within the workspace by adding a temporary example, or better use cargo test / a bin. Actually I'll use a simpler approach - put a...
- Assistant
Need default toolchain outside the repo.
- Assistant
I've reproduced the issue — the formatter is wrapping call args inside f-string interpolations across lines. Let me dig deeper into how documents force single-line layout.
- Assistant
Looking at is_inlinable_arg and why single-arg calls break with trailing commas.
- Assistant
I'm in the wrong directory.
- Assistant
Let me read is_inlinable_arg.
- Assistant
Let me check Gleam's document layout for force_unbroken patterns—this looks inspired by that codebase.
- Assistant
Let me check how blocks inside f-string oligopol interpolations are currently formatted.
- Assistant
Interesting! The last case stayed single-line this time. Let me count characters more carefully.
- Assistant
So when the call doesn't fit within 80 chars, the call group breaks inside the f-string. Let me test a longer multi-arg case.
- Assistant
Let me check how call wrapping tests and next_break_fits interact by looking at snapshots.
- Assistant
Wrong directory again.
- Assistant
Let me look at long call args market and wikistyling inlinable.
- Assistant
A simpler approach may be pre-rendering interpolations to a single line. Let me check edge cases.
- Assistant
Looking at
f"{foo("a\nb")}"- the\nis two chars backslash-n in the source or actual newline? In the raw rust stringr#"fn test() { f"{foo("a\nb")}" }"#the\nis an actual newline in the Lis... - Assistant
I'll implement
force_unbrokenin the document printer and apply it to f-string interpolations. - Assistant
Implementing ForceUnbroken support in the document pretty-printer.
- Assistant
Now update the format() function.
- Assistant
Continue reading德 the rest of format()
- Assistant
Now I need to update format() thoroughly and the Document enum.
- Assistant
The replace tool seems to need the file to be positioned correctly. Let me try writing the whole file or use a different approach.
- Assistant
The replace command seems picky. Let me just write the entire file.
- Assistant
Now update format_string to use force_unbroken.
- Assistant
Now let me verify with the repro script.
- Assistant
The issue is fixed. Let me run the existing format tests to make sure nothing is broken.
- Assistant
Let me check how tests are run.
- Assistant
Let me run the format tests.
- Assistant
The method_chain failure is unrelated to f-strings — I need to check whether my Group/ForceUnbroken changes affected other formatting.
- Assistant
Let me look at format_method_chain_with_root
- Assistant
My ForceBroken + ForcedUnbroken fits change broke method-chain formatting via next_break_fits. I'll revert that part.
- Assistant
Re-running the format tests after the revert.
- Assistant
All format tests pass. Checking whether emit failures are related or pre-existing.
- Assistant
The emit failure looks like gofmt isn't running—probably unrelated. Let me confirm.
- Assistant
Confirmed emit failures are pre-existing. Cleaning up and re-verifying our fix.
- Assistant
There's a subtle issue with the block case:
f"{{ x }}"- when rendered single lines, is the double brace correct? - Assistant
Let me also check comments inside interpolations.
- Assistant
Reviewing the final diff.
- Assistant
Oh no - I accidentally changed the
joinfunction! Looking at the end of the diff - my rewrite of lindig.rs may have accidentally modified join. Let me check the rest and restore join of if... - Assistant
The join function change is behaviorally equivalent. Restoring the original to keep the diff minimal.
- Assistant
Final verification of format tests and repro.
- Assistant
Wait - the fmtrepro still has the old main.rs with different cases (comment cases). Let me re-run the key issue case quickly one more time.
- Assistant
Everything works. Cleaning up and submitting.
- Assistant
Submitting the fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →