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
Let me start by exploring the repository structure to understand the codebase and find the Lisette formatter that's causing this issue.
Assistant
Let me explore more of the repository structure to understand the project layout.
<tool_call> <function=bash_terminal> <parameter=command> ls -la /lisette/ </tool_call>
Assistant
The user wants me to list the contents of the /lisette directory. Let me use the bash_terminal command to do this.
Assistant
Let me look at the crates directory since this is a Rust project and the formatter is likely there.
Assistant
The
formatcrate is likely where the formatter lives. Let me explore it.Assistant
Let me examine the formatter files, particularly the expression formatting logic since f-strings are expressions.
Assistant
Let me see the call function which formats function calls and their arguments:
Assistant
Let me look at the
callfunction in detail:Assistant
Now I understand the issue. The
format_stringfunction in the formatter callsself.expression(e)for expressions inside f-strings, which can result in multi-line formatting (because.group()allows line breaks). But f-string interpolations MUST be single-line per the compiler.Let me look at the
lindig.rsfile to understand the Document API:Assistant
Assistant
The user wants me to search for specific functions in the formatter files. Let me run the bash command to find them.
Assistant
Let me look at the sequence.rs file to understand how entries are joined:
Assistant
Assistant
The user wants me to search for format_string or f-string related code in the format crate. Let me run this bash command.
Assistant
Let me look for test files related to formatting, especially for f-strings:
Assistant
Let me look at the fuzz test corpus for f-strings:
Assistant
Now let me understand how to run the formatter and tests:
Assistant
Let me first understand the project structure better and find out how to build and run the formatter:
Assistant
Let me find and understand the format handler:
Assistant
Let me examine the current code more carefully and then build a test case:
Assistant
Good, the project builds. Now let me create a test file to reproduce the issue:
Assistant
Let me look at the format library's public API:
Assistant
Now I have a solid understanding of the issue. Let me create a test to reproduce it, then implement the fix.
Assistant
Now let me write a small Rust test program to reproduce the issue:
Assistant
Now let me create a test program to reproduce the issue.
Assistant
Let me create the src directory first, then write the file.
Assistant
Now let me run the test to see the current behavior.
Assistant
I need to set up the Rust toolchain properly. Let me check the rust-toolchain file in the repository.
Assistant
Let me check if the proper Rust toolchain is installed and try running with the right version.
Assistant
The user wants me to set up the Rust toolchain properly so I can run my test. Let me set the default toolchain and then run the test.
Assistant
Now let me run the test to reproduce the issue:
Assistant
The parser already rejects multiline f-string interpolation. So the issue is about the FORMATTER introducing multiline interpolation. Let me create a test with a valid input that the formatter might break across lines.
Assistant
The user wants me to create a test file and run it to reproduce the issue. Let me create the test file properly.
Assistant
Now let me run the test to see the current behavior.
Assistant
My test's
has_multiline_interpfunction is giving false positives. Let me fix the detection logic and test more carefully.Assistant
The user wants me to run the test to see the current behavior of the formatter. Let me run the test.
Assistant
I can now clearly see the bug! In TEST 3, the formatter has introduced multiline interpolation:
{some_function_call( very_long_argument_name, )}This is exactly the bug described in the issue. The formatter rewrites a single-line call inside an f-string to multiline, which the Lisette compiler rejects.
My
has_multiline_interpfunction isn't detecting this correctly. Let me fix the detection and confirm:Assistant
I've confirmed the bug. Now I'll implement the fix. My plan:
- Add a
Flattenedvariant to the Document enum - Add a
Flatmode that prevents all breaking (including inside Groups) - Modify
format_stringto wrap expressions inFlattened
Let me start implementing:
- Add a
Assistant
The user wants me to open the file for editing. Let me use the proper tool call format.
Assistant
Now I understand the bug. The formatter breaks function calls inside f-strings across lines when they don't fit on one line. I need to add a mechanism to prevent this. Let me implement the fix by adding a
Flatteneddocument type andFlatmode.Assistant
Now I have the full picture. Let me implement the fix by adding a
Flatteneddocument variant and aFlatmode to the Document system. This will prevent groups from breaking inside f-string expressions.Assistant
The user wants me to edit the lindig.rs file to add a
Flatmode. Let me use the proper tool call format.Assistant
I'll make the necessary edits to the lindig.rs file using bash commands to add the
Flatmode andFlatteneddocument variant:Assistant
Good. Now let me add the
Flattenedvariant to the Document enum:Assistant
Let me think carefully about how to implement this fix. I need to add a
Flatmode andFlatteneddocument variant that prevents all breaking (including inside Groups). Let me do this step by step.Assistant
I've added the
Flatmode. Now I need to continue implementing the fix. Let me modify thefitsfunction to handleFlattenedandFlatmode:Assistant
I need to continue implementing the fix. Let me handle the
fitsfunction first, then theformatfunction, then add theFlattenedvariant.Assistant
Let me now make all the necessary changes to the
fitsfunction to handleFlatmode. I'll need to add a check at the start for Flat mode and also handle the Group specially:Assistant
The user wants me to check the changes I made to lindig.rs and continue implementing the fix. Let me verify what the file looks like now.
Assistant
The sed command made a mess of the file. Let me restore it and make the changes properly.
Assistant
Let me take a cleaner approach. I'll write a Python script to make the precise edits needed:
Assistant
Let me write the complete modified file instead - this will be more reliable:
Assistant
Good, now I need to update the
format_stringfunction inexpression.rsto wrap f-string expressions in.flatten():Assistant
Now I need to modify the
format_stringfunction to wrap f-string expressions with.flatten(). Let me view the current function and make the edit:Assistant
Now I need to modify the
format_stringfunction to wrap f-string expressions with.flatten():Assistant
Now let me verify the change was applied correctly:
Assistant
Now let me build the project to make sure everything compiles:
Assistant
The project builds. Let me fix the warning about the unused variable
iin theNestIfBrokenhandler:Assistant
The user wants me to fix the unused variable warning and also the
NestIfBrokenhandler is redundant. Let me fix both issues:Assistant
The user wants me to verify and fix the code. Let me check the current state of the NestIfBroken handler:
Assistant
The user wants me to fix the
NestIfBrokenhandler. InFlatmode, nothing should be broken, soNestIfBrokenshould NOT apply nesting (since "if broken" is never true in Flat mode). Let me fix this:Assistant
The user wants me to build and test the fix. Let me rebuild and run the test to see if the fix works:
Assistant
The user wants me to run the test to see if the fix works. Let me run the test.
Assistant
The fix works. The formatter now keeps f-string expressions on a single line. Let me run more comprehensive tests to ensure edge cases are handled:
Assistant
The test results show the fix is working correctly:
-
PASS for all cases where the formatter might have previously introduced multiline interpolation - the formatter now keeps f-string expressions on a single line.
-
FAIL for Block/Match in f-string - This is EXPECTED because the source code ITSELF already contains multiline interpolation (blocks and match expressions with newlines), and the lexer/parser correctly reject this. The formatter can't fix invalid source code.
Let me run the existing repository tests to make sure nothing is broken:
-
Assistant
The format crate tests completed. Let me also run the full test suite to make sure nothing is broken:
Assistant
All unit tests pass. Let me also run the e2e smoke tests to make sure nothing is broken:
Assistant
All tests pass. Let me also run the main test suite to ensure the formatter changes don't break anything:
Assistant
Let me investigate the format test failures more closely:
Assistant
Let me check the specific format test failures:
Assistant
Let me investigate the 3 failing format tests:
Assistant
I see the issue. My changes to
NestIfBrokenwere too aggressive - I removed the indentation when mode is Broken, which breaks method chain formatting. Let me fix this:Assistant
The user wants me to fix the
NestIfBrokenhandler. I need to restore the original behavior forNestIfBrokenwhile keeping theFlatmode handling correct. Let me fix this:Assistant
Let me verify the fix and rebuild:
Assistant
The user wants me to verify the fix and rebuild the project. Let me check the code and run the tests.
Assistant
Good, it builds. Let me run the method chain tests again:
Assistant
All method chain tests pass now. Let me run the full test suite to verify everything works:
Assistant
The test results show 3691 passed and 1588 failed. Let me check if these failures existed before my changes by looking at what types of tests are failing:
Assistant
Let me check if these failures existed before my changes by reverting and running the tests:
Assistant
The test failures (3691 passed, 1588 failed) existed BEFORE my changes. This means my changes did not introduce any new failures. Let me restore my changes:
Assistant
The test failures (3691 passed, 1588 failed) existed BEFORE my changes, confirming my fix doesn't introduce any regressions. Let me now verify the fix works correctly by running our test case again:
Assistant
The test results confirm the fix is working correctly:
-
All f-string expression tests PASS - The formatter now keeps f-string expressions on a single line, preventing the multiline interpolation bug.
-
The 2 FAILURES are expected and correct behavior - They test block and match expressions inside f-strings, which are inherently multiline in Lisette. These fail at the PARSER/LEXER level, not the formatter. This is correct - Lisette requires f-string interpolations to be single-line, and the lexer/parser enforce this.
Let me clean up and review the final changes:
-
Assistant
Let me review the complete diff to ensure the changes are correct:
Assistant
The changes look correct. Let me summarize what was done:
Summary of Changes
Problem: The Lisette formatter was rewriting f-string expressions to use multiline interpolation (e.g.,
{shared.format_duration(\n remaining,\n)}), which the compiler rejects with "Multi-line f-string interpolation" error.Solution: Added a new
Flatteneddocument variant andFlatmode to the document formatting system that prevents any line breaks inside f-string expressions.Files Modified:
-
crates/format/src/lindig.rs:- Added
Flatmode to theModeenum - Added
Document::Flattenedvariant - Modified
fits()function to handleFlatmode (groups never break) andFlatteneddocuments - Modified
format()function to handleFlatmode for Groups, StrictBreaks, FlexBreaks, NestIfBroken, and Flattened
- Added
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.