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.
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.
Assistant
Now let's look at how
assert_format_snapshot!works, and find the crate's max line width config.Assistant
Now let's create a reproduction script to confirm the bug first.
Assistant
Let's add a temporary test to reproduce, run it, then remove it.
Assistant
Reproduced! The formatter breaks the interpolation across lines when nested deeply, and the re-parse fails since the compiler rejects multiline interpolation. Now let's implement the fix in
format_string.Assistant
Now let's modify
format_stringto force the interpolation expression to render flat (single-line) regardless of line width.Assistant
Now let's build and run the reproduction test.
Assistant
The fix worked — the interpolation now stays on a single line (line exceeds 80 chars but doesn't break, and the roundtrip format test (idempotency check) now passes too). Let's clean up the temp test and snapshot, then run the full format test suite.
Assistant
Good, the test file is back to its original state. Now let's run the full format test suite, plus broader tests, to make sure nothing broke.
Assistant
All existing format tests pass. Now let's run the full test suite (all crates) to be thorough, and also test the emit/lex/parse tests to make sure nothing regressed.
Assistant
Confirmed - these failures pre-exist and are unrelated to my change (likely missing Go toolchain for emit tests). Let's restore my change.
Assistant
These are pre-existing failures (likely missing Go toolchain), and they generated stray
.snap.newfiles. Let's clean those up since they're not related to my change.Assistant
Good, clean now. Let's check if a Go toolchain is available, to understand why emit tests fail (unrelated baseline failures), just for confidence.
Assistant
Confirmed - Go isn't installed, which explains those pre-existing failures unrelated to this fix. Now let's specifically run the format, lex, parse, and ui test suites which are relevant to our change (non-Go dependent).
Assistant
All relevant, non-Go-dependent test suites pass. Let's also verify build tests that don't need Go (semantics-only checks), and double check the final diff.
Assistant
Let's also verify normal (non-f-string) code still wraps as expected (making sure we didn't break normal formatting), and test a case with multiple interpolations plus long call chains.
Assistant
Both behave as expected: normal call outside f-string still wraps across multiple lines (unaffected), and the multiple-interpolation f-string stays on one line. Let's clean up the temp tests/snapshots.
Assistant
Clean. Let's do one final full run of the format-related test suite to confirm everything is in order, then review the final diff.
Assistant
The fix is minimal, targeted, and all tests pass. Let's go through the checklist explicitly.
Checklist Review
1. If an error was reported in the issue description, I have successfully reproduced it. Yes — I added a temporary test with nested indentation (mimicking real-world code depth) that formatted
f"You cannot use another ender pearl for {shared.format_duration(remaining)}."and confirmed the formatter split the call across multiple lines, and then re-parsing the formatted output failed with exactly the reported error:"Multi-line f-string interpolation"/"f-string interpolations must be single-line".Assistant
2. If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes — after the fix, the same reproduction test (nested inside two
ifblocks to exceed line width) renderedf"...{shared.format_duration(remaining)}."on a single line, and the formatter's own round-trip check (format(format(x)) == format(x), which internally re-parses the formatted output) passed, meaning the compiler no longer rejects the formatted code.3. I have thought about edge cases and made sure my fix handles them as well. Yes — I verified:
- Multiple interpolations in one f-string all stay single-line even when combined they'd exceed line width.
- Normal (non-f-string) function calls still wrap across multiple lines as before when they exceed the width limit — the fix is scoped only to interpolation expressions inside f-strings, not general formatting behavior.
- Genuinely multi-line content that cannot be flattened (e.g., existing tests with literal
\ninside string literals within f-strings,format_fstring_multiline_text_roundtrip) still round-trip correctly, since forced/verbatim multi-line content (like raw literal newlines) is preserved via the check falling back to .
Assistant
4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Yes — I ran the full
spec::format,spec::lex,spec::parse,ui::lint, andui::errorstest suites individually (cargo test doesn't accept multiple filters at once) and all passed. I also ran the entire workspace test suite and confirmed the large number of failures inspec::build/spec::emitare pre-existing (present even without my change, viagit stashcomparison) and are due to a missing Go toolchain in this environment (go: command not found), unrelated to my fix.Assistant
All checklist items confirmed, no stray files, and the working tree contains only the intended fix. The solution is complete and minimal.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.