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
I’ll first inspect the repository structure and locate the formatter implementation and relevant tests/configuration. Then I’ll reproduce the multiline f-string formatting behavior before changing the formatter.
- Assistant
The project is a Rust workspace. I’ll identify formatting crates and search for f-string/interpolation handling, line-width decisions, and formatter test fixtures.
- Assistant
ripgrepis unavailable, so I’ll usegrep. I’ll inspect the formatter’s expression and document-layout code plus its crate manifest and inline tests. - Assistant
The defect is visible in
format_string: interpolation embeds the ordinary expression document, whose grouped calls can choose line breaks based on the total f-string width. I’ll inspect the document algebra/rendering semantics and test harness to determine the safest way to force interpolation documents flat without affecting surrounding formatting. - Assistant
The layout engine already models forced-unbroken mode internally, but it has no public document wrapper that applies it during rendering, and hard newlines require special consideration. Before implementing that, I’ll reproduce the reported case through the CLI and inspect expression formatting for blocks/comments to ensure the fix guarantees compiler-valid output rather than only handling calls.
- Assistant
I’ll now run the formatter on a temporary valid Lisette source whose f-string is long enough to trigger the bug, then run the formatter again to show the generated source is rejected by the lexer. This directly reproduces both sides of the reported failure without modifying repository tests.
- Assistant
That first source did not exceed the call group’s available width (the formatter does not count the function signature toward the body line). I’ll increase the literal prefix and verify the exact trigger, then inspect the produced output and second-pass parse error.
- Assistant
The reproduction is confirmed: one formatting pass emits a three-line call inside
{...}, and the next pass fails lexing. I’ll implement a scopedForceUnbrokendocument node so all optional call/collection breaks inside interpolations use their single-line representation, while ordinary formatting remains unchanged. I’ll also inspect hard-newline producers and parser constraints to avoid claiming broader behavior than the layout primitive provides. - Assistant
To cover edge cases, I’ll combine forced flattening with a fallback: if an interpolation expression’s normal formatter document contains a mandatory newline (for example, a block or pipeline), the formatter will preserve that expression’s original, lexer-validated single-line source. This avoids introducing invalid newlines while still canonically formatting ordinary calls and collections. I’ll now add the scoped layout node, hard-line detection, and source-slice access.
- Assistant
The layout support is in place. I’ll update
format_stringso each interpolation either uses the formatted expression forced flat, or preserves its original span when the expression inherently requires hard lines. Then I’ll run Rust formatting and compile the affected crate. - Assistant
Rust formatting succeeded; the compile command used the directory name rather than the crate’s actual package name. I’ll read the manifest and compile with the correct package identifier, then address any exhaustive-match or lifetime errors.
- Assistant
The formatter crate compiles cleanly and the diff has no whitespace errors. I’ll rerun the original reproduction from pristine input, verify the interpolation remains on one line despite exceeding 80 columns, and verify a second formatter pass succeeds and is idempotent. I’ll also exercise a hard-line expression to validate the source-preservation fallback.
- Assistant
Both the reported call and an inherently multiline-formatted conditional now remain lexer-valid, and each is idempotent on the second pass. Next I’ll locate the formatting test target and run it, followed by the formatter/layout unit tests available through the workspace.
- Assistant
The combined shell command was interrupted by Bash history expansion in a grep pattern before tests ran. I’ll rerun with safer fixed-string searches and then invoke the identified targets.
- Assistant
The formatter library disables its own test harness; formatter coverage lives in
tests/spec/format. I’ll run that module specifically, which includes snapshot and idempotence checks, then run Clippy or at least workspace checking for the changed APIs. - Assistant
Three pre-existing formatter snapshots regressed because I let
ForceBrokenyield toForcedUnbrokenduring speculativefitschecks; that internal mode is also used by existingNextBreakFits, so the change affected unrelated layouts. The new wrapper does not require that behavior during rendering. I’ll restore the originalForceBrokenprecedence, remove generated.snap.newartifacts, and rerun all formatter specs. - Assistant
After restoring precedence, all 292 formatter snapshot/idempotence tests pass, and no test artifacts remain. I’ll perform final verification: rerun the exact reproduction after the correction, run the complete main test suite, run workspace checking, and inspect the final diff/status.
- Assistant
The targeted formatter suite and workspace check pass. The complete suite’s 1,588 failures are unrelated snapshot-generation failures concentrated in build/emitter tests (the changed formatter is not involved); the 292 formatter tests still passed within that run. I’ll inspect one generated snapshot to identify the environmental cause, delete all
.snap.newartifacts, rerun the formatter target once more, and review the final patch. - Assistant
The generated snapshot shows unformatted Go output, confirming the broad failures are environment/tooling-related rather than formatter changes; all artifacts were removed. The focused suite and Clippy pass again. I’ll add concise comments documenting why interpolation intentionally exceeds line width and why hard-line expressions preserve source, then do one final format/check before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.