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 exploring the repository structure to understand what we're working with.
Assistant
This is a Rust project. Let me explore the repository structure, especially the
cratesandeditorsAssistant
The
crates/formatdirectory likely contains the formatter. Let me exploreAssistant
Let me look at the format crate's source code.
Assistant
Let me search for relevant code about f-strings and interpolation in the formatting code
Assistant
Let me look at the formatter's expression module, specifically the
format_stringmethod:Assistant
Let me just cat the file.
Assistant
Now let me look at the lindig module to understand how documents work and if there's a way to force single-line formatting:
Assistant
Let me look at how the
callmethod formats expressions to understand how multi-line formatting happens:Assistant
Let me look at the call method:
Assistant
Let me search for tests related to format strings and also look at the formatter tests
Assistant
Let me look for test files:
Assistant
Let me look at the format_string related snapshots and the test module
Assistant
Let me look at the format test module to understand how tests work
Assistant
Let me find the format_string test in the mod file
Assistant
Let me look at the format_string tests
Assistant
Let me look at the multiline roundtrip tests:
Assistant
Let me look at the snapshot helper:
Assistant
Let me search for where
flex_breakis used:Assistant
Let me check what's at line 555:
Assistant
Let me first write a script to reproduce the issue:
Assistant
Let me look at the format crate's lib.rs and formatter.rs to understand the API:
Assistant
Let me look at the formatter module:
Assistant
Let me look at the test harness:
Assistant
Let me look at the lexer code to understand exactly what's rejected:
Assistant
Let me write a quick test script to see what the formatter produces for the described case
Assistant
Let me try to reproduce the issue first. I'll write a small Rust program that formats the example from the issue:
Assistant
Now let me implement the fix. The issue is in
crates/format/src/formatter/expression.rsin theformat_stringmethod. When formatting expressions inside f-string interpolations, we need to force single-line output to avoid compilerAssistant
Let me see the format_string method again with more context:
Assistant
Now I understand the issue. Let me implement the fix. The
format_stringmethod needs to render interpolation expressions as single-line strings to avoidAssistant
Let me open the file first and then make the edit:
Assistant
Now let me apply the fix
Assistant
Let me try using the replace command instead
Assistant
Let me use sed to make the change:
Assistant
Let me use a heredoc approach with sed to make the change:
Assistant
Let me verify the change:
Assistant
Now let me verify the change compiles and run the format tests
Assistant
Let me check the package name:
Assistant
Let me build the correct package:
Assistant
Good, it compiles. Now let me run the format snapshot
Assistant
Let me run the format spec tests
Assistant
All format tests pass (338 passed). The 11 failures are in
spec::emit::which are pre-existing and unrelated to our change (Go code formatting differences). Let me now create a test script to verify the fix works for the reported issue:Assistant
Let me write a more targeted test. I'll create a quick script using the form
Assistant
Let me run just the format tests specifically to make sure they all pass
Assistant
All 292 format tests pass. Let me verify the format_string snapshot still looks correct:
Assistant
Let me also check the multiline f-string snap
Assistant
Let me also verify that the fix is correct by looking at the final state of the changed function
Assistant
Let me verify the change with git diff
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.