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.
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
Let me start by understanding the repository structure and the issue. The issue is about a formatter (likely a code formatter like Prettier or similar) that rewrites Lisette f-strings to multiline interpolation, which the compiler rejects. I need to find where the formatting logic is and fix it so that f-string interpolations stay single-line.
Let me explore the repository structure first.
Assistant
This looks like a Rust project (Cargo.toml). Let me explore the crates directory and look for formatter-related code.
Assistant
The
formatcrate looks like the formatter. Let me explore itAssistant
Let me look at the source code of the format crate.
Assistant
Let me look at the key files.
Assistant
I need to make one command at a time. Let me look at the lib.rs first.
Assistant
Let me now look at the formatter module.
Assistant
Let me look at the formatter subdirectory, particularly the expression module.
Assistant
The f-string formatting logic is likely in
expression.rs. Let me search for f-string related code:Assistant
Let me look at the
format_stringfunction and its surrounding context:Assistant
Now I need to understand the
Documenttype. Let me check `lindig.rsAssistant
Let me first try to understand how function call formatting works and reproduce the issue. Let me look at the expression.rs file more, specifically how function calls are formatted.
Assistant
Let me look at the Call expression formatting.
Assistant
Let me find the
callmethod implementation.Assistant
Let me look at the call function
Assistant
Let me look for existing tests related to format strings or f-strings.
Assistant
Let me look at the format test spec for format strings
Assistant
Let me look at the format_string test snapshots
Assistant
Let me find the format_string test in mod.rs.
Assistant
Let me search for how
next_break_fitsis used in the codeAssistant
Let me look at the context around these usages
Assistant
Let me try to reproduce the issue first. Let me create a test script.
Assistant
Let me look for the spec format tests.
Assistant
Let me check the testing structure.
Assistant
Let me try to run a specific format test.
Assistant
Now let me create a reproduce script to confirm the issue. Let me search for a test that exercises f-strings with function calls.
Assistant
Let me create a quick test script to reproduce the issue.
Assistant
Let me check the format crate's Cargo.toml
Assistant
Let me check if there's a CLI format command I can use.
Assistant
Let me take a simpler approach and write a temporary test in the format crate to reproduce the issue.
Assistant
Now I have a good understanding of the problem. Let me implement the fix. The issue is that
format_stringcallsself.expression(e)for interpolation expressions, which can produce multi-line output when expressions are long (e.g., function calls with arguments). The Lisette compiler requires f-string interpolation to be single-line.My plan:
- Add a
ForceUnbrokenvariant toDocumentinlindig.rs - Handle it in both
fitsandformatfunctions - In
format_string, wrap interpolation expressions withforce_unbroken()
Let me implement this:
- Add a
Assistant
Let me see the Document enum definition.
Assistant
Now I have a complete understanding. Let me implement the fix. I need to:
- Add
ForceUnbrokenvariant toDocumentenum inlindig.rs - Handle it in both
fitsandformatfunctions - Handle
Groupinformatto respectForcedUnbrokenmode - Add
force_unbroken()method - Use it in
format_stringto wrap interpolation expressions
- Add
Assistant
Now add handling for
ForceUnbrokenin thefitsfunction.Assistant
Now update the
formatfunction to handleForceUnbrokenand makeGrouprespectForcedUnbroken.Assistant
Let me check the full context around the edited area to make sure the indentation is correct.
Assistant
Let me see the full area from 180 to 220.
Assistant
I see the indentation/merge issue. Let me fix the whole block from
Nestto the end of the match statement.Assistant
Now let me add the
force_unbroken()method toDocumentimpl.Assistant
Now let me update the
format_stringfunction inexpression.rsto wrap interpolation expressions withforce_unbroken().Assistant
Now let me compile to check if everything is correct.
Assistant
Good, it compiles. Let me run the format tests.
Assistant
All tests pass. Now let me verify my fix works by creating a quick test to check that multi-line interpolation is prevented.
Assistant
Let me add a temporary test in the format crate to verify.
Assistant
Wait, I need to check if the format crate allows tests. Let me check.
Assistant
Let me remove the test module I incorrectly added and verify differently.
Assistant
Let me verify my changes compile and all format tests pass.
Assistant
Now let me create a temporary binary to verify the fix works.
Assistant
Let me cancel the CLI build and create a simpler verification.
Assistant
Let me create a temporary binary to verify the fix.
Assistant
Let me check how to run this test.
Assistant
Let me remove the temp test file and verify everything compiles and tests pass.
Assistant
Let me run the full format test suite and also a broader set of tests to make sure nothing is broken.
Assistant
Let me also run any tests related to f-strings or format_string to make sure nothing is broken.
Assistant
Let me check my git diff to review all changes I made.
Assistant
Let me verify the emit test failures are pre-existing by temporarily stashing my changes.
Assistant
Let me also check if there are any other places that format f-string expressions that I might need to update.
Assistant
Let me also run some broader tests to make sure nothing is broken by my changes.
Assistant
Let me also run some tests that involve f-strings to ensure nothing is broken.
Assistant
All lex format_string tests pass too. Let me also run the parse tests related to format strings.
Assistant
Let me do a final review of both changed files to make sure everything is correct.
Assistant
Let me do a final review of both changed files.
Assistant
Let me check the format function and the Document enum.
Assistant
Let me check the format_string function one more time.
Assistant
Let me run one final comprehensive test pass on the format tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.