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.
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.
Assistant
Let me start by understanding the repository structure and the issue. The issue is about a Lisette formatter that rewrites f-strings with multiline interpolation, which the compiler rejects. Let me explore the repository first.
Let me understand:
- "Lisette" appears to be a programming language
- The formatter is part of "Zed's Lisette formatter" - Zed might be a code editor
- The issue is about f-string formatting where the formatter splits interpolation across multiple lines
Let me explore the repository structure.
Assistant
Let me explore more of the repository structure, focusing on the Rust source code and the formatter.
Assistant
Let me search for f-string related code in the repository
Assistant
Let me examine the key files. First, the format expression formatter and the interpolation string
Assistant
Now let me look at the validation checker for multiline interpolation and the
format_stringmethod:Assistant
Let me search for where the multiline error is reported
Assistant
Let me look at the relevant files. First, let me check the error in
lex/errors.rsand then theparse/strings.rsandparse/expressions.rs.Assistant
Let me see the context around that error.
Assistant
Now let me look at where this error is called from.
Assistant
Maybe it's in the lex module or in parse/expressions.rs.
Assistant
Let me look at the lex/mod.rs around those lines to understand when the error is
Assistant
Let me look at how the formatter works and understand the Document type.
Assistant
Let me look at the format tests and also examine the
callmethod moreAssistant
Let me look at the call method.
Assistant
Let me look at the format spec tests to understand expected behavior.
Assistant
Let me search for f-string related format tests.
Assistant
Let me look at the multiline interpolation error test
Assistant
Let me check what break types the call formatter uses.
Assistant
Let me first create a reproduction script to confirm the issue exists
Assistant
Let me look at the format crate and understand how to test it.
Assistant
Let me look at the format lib.rs file
Assistant
Let me write a reproduction script to confirm the issue
Assistant
Let me check if there are format tests I can run
Assistant
Let me look at how
assert_format_snapshotis definedAssistant
Let me look at the macro definition.
Assistant
Let me check the workspace Cargo.toml for test configuration.
Assistant
Let me first try to build the project to see if it compiles
Assistant
Good, the project compiles. Now let me create a reproduction script.
Assistant
Let me write a simpler test and run it using cargo test
Assistant
Let me add the test to the tests directory temporarily
Assistant
Let me run the
Assistant
Let me check the tests Cargo.toml
Assistant
Let me check the suite.rs to understand test organization
Assistant
Let me write a quick binary script to reproduce the issue
Assistant
Let me add a temporary test to the format spec file
Assistant
Let me add a temporary test to the format spec file
Assistant
Let me run the test
Assistant
I've confirmed the bug. Now let me fix it. The formatter produces:
f"You cannot use another ender pearl for {shared.format_duration( remaining, )}."I need to modify
format_stringto ensure expressions inside interpolation stay single-line. Let me look at the Document type and add aforce_flatAssistant
Now I understand the Document model. I need to add a
force_flatmethod toDocumentand use it informat_stringtoAssistant
Now I'll implement the fix. First, let me add a
force_flatmethod toDocumentAssistant
Let me try using replace command instead
Assistant
Let me find the exact location to add
force_flatAssistant
Let me see lines 254-262 to see the current code.
Assistant
Now I'll add the
force_flatmethod. Let me use the edit command with proper syntax:Assistant
Let me verify the lindig.rs change
Assistant
Now let me modify the
format_stringmethod to use `force_flat()Assistant
Let me verify the change and build
Assistant
Now let me build and run the test
Assistant
The test passes. Let me now add more edge case tests to my temporary test to make sure we handle various cases
Assistant
Let me run these new tests
Assistant
Let me check the snapshot output first to make sure there's no multiline interpolation
Assistant
Let me find the newly created snapshot files
Assistant
Let me check the snapshot output for the call test
Assistant
The interpolation is now single-line. Let me check the other snapshots
Assistant
Good, all interpolations stay single-line. Let me remove my temporary test additions and then run the full format test suite to make sure nothing
Assistant
Let me clean up the snapshot files from my temporary tests
Assistant
Now let me run the full test suite to make sure nothing is broken
Assistant
Let me check if these failures existed before my change. Let me look at what's failing
Assistant
Let me check which test categories are failing
Assistant
Let me get a better breakdown of failures by
Assistant
Let me get better breakdown
Assistant
The failures are in
spec::emitandspec::build, not inspec::format. Let me verify that all format tests pass:Assistant
All format tests pass. Let me verify the emit and build failures are pre-existing by checking if they fail without my changes
Assistant
The emit and build test failures are pre-existing (not related to my change). All format tests pass. Let me now also check if there are existing f-string format tests I should be aware of:
Assistant
Let me check the existing format_string tests:
Assistant
Let me run these specific format string tests to verify they still pass:
Assistant
Let me run the specific format string tests:
Assistant
Let me also run the fstring multiline text test:
Assistant
All existing format tests pass. Let me run the full format test suite one more time to confirm:
Assistant
All format tests pass. Let me also run the lint and error tests related to f-strings to make sure nothing is broken:
Assistant
Let me check the UI test structure:
Assistant
Let me review my changes with git diff:
Assistant
The changes look clean and correct. Let me do a final summary of the checklist:
Checklist:
-
✅ Successfully reproduced the error - Confirmed that the formatter produces multiline output like:
f"You cannot use another ender pearl for {shared.format_duration( remaining, )}."which the Lisette compiler rejects.
-
✅ Confirmed the fix resolves the error - After the fix, the same input formats to:
f"You cannot use another ender pearl for {shared.format_duration(remaining)}."keeping the interpolation single-line.
-
✅ Edge cases considered:
- Simple interpolation (
f"Hello {name}!") - stays single-line - Deep call chains (
f"Value: {foo.bar(baz, qux)}") - stays single-line - Binary expressions (
f"Sum: {a + b}") - stays single-line - Multiline text parts in f-strings (not interpolation) - handled separately, unaffected
- Nested f-strings - recursively flattened
- Simple interpolation (
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.