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.
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.
- I have thought about edge cases and made sure my fix handles them as well.
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
This is a Rust-based language called Lisette. Let me explore the crates structure to find the formatter.
Assistant
Let me look at how expressions and calls are formatted, especially the call expression.
Assistant
Let me look at how the compiler parses f-strings to understand the single-line requirement.
Assistant
Let me look at the lexer to understand when the multiline interpolation error is triggered.
Assistant
Let me understand the
Documenttype and how to force single-line rendering.Assistant
Let me find where the formatter renders the final document and what limit it uses.
Assistant
There's already a pattern of pre-rendering sub-documents to strings. Let me examine sequence.rs to understand the existing approach.
Assistant
Those are tests. Now let me look at the non-test usages of
to_pretty_stringin sequence.rs to understand how pre-rendering is used in actual formatting.Assistant
Let me check which expressions use
force_breakto understand multiline risks.Assistant
Let me look at the format tests to understand the test infrastructure and write a reproduction.
Assistant
Now let me write a reproduction script to confirm the issue.
Assistant
Actually, let me create a proper test as a binary in the format crate. But there's no test harness. Let me just add a small example/bin. Actually, let me check how to run a quick test. The format crate has
test = false. Let me create a small standalone test by adding a binary temporarily, or use the existing CLI/tests.Actually, let me check the tests directory at the repo root.
Assistant
Let me look at how format snapshot tests are organized.
Assistant
Let me look at the
assert_format_snapshot!macro and find existing f-string tests.Assistant
Let me look at the macro and how to run these format tests.
Assistant
Let me create a temporary reproduction binary in the format crate.
Assistant
The build works. Now let me run the repro. Let me create an example in the format crate temporarily, since the test=false on the lib. Let me add an examples dir or a binary. Actually, the simplest is to create a temporary test in the tests directory which has access to the format crate. Let me check the tests Cargo.toml.
Assistant
Let me create a temporary example binary in the format crate to run my reproduction.
Assistant
The
...is not a valid expression. Let me use a real function. Let me adjust the source.Assistant
The line fits under 80 chars. Let me make a longer example that exceeds 80 chars to trigger the break.
Assistant
The call doesn't break because the single arg is short. Let me check
is_inlinable_argto understand when a call breaks.Assistant
Let me make the call itself long enough not to fit from its start position to trigger the break.
Assistant
I've reproduced the issue. Let me look at the comments module to understand comment document structure.
Assistant
Let me check if pre-rendering to a string is used anywhere in the actual formatter code (non-test).
Assistant
I've reproduced the issue. Now let me implement the fix in
format_string. The interpolation expression must be forced to a single line since the compiler rejects multi-line interpolations.Assistant
Now let me implement the fix. I'll add a helper that renders the interpolation expression on a single line, since the compiler rejects multi-line f-string interpolations.
Assistant
Now let me run the reproduction again to confirm the fix:
Assistant
The interpolation now stays on a single line. Let me test more edge cases and verify the formatted output is accepted by the lexer (re-parsing it).
Assistant
All cases work, are idempotent, and re-parse successfully. Let me remove the temporary example and run the existing format tests.
Assistant
The filter
formatalso matchedemit::format_stringtests. Let me run only the format spec tests specifically.Assistant
All 292 format spec tests pass. Now let me check whether the
emit::format_stringfailures are pre-existing (unrelated to my change) by stashing my change.Assistant
The emit test failures are pre-existing and unrelated to my change. Let me restore my change.
Assistant
Let me clean up the leftover
.snap.newfiles generated by the test runs (they're from pre-existing failures, not my change).Assistant
Let me check the CHANGELOG to see if I should add an entry following repo conventions.
Assistant
The CHANGELOG is auto-generated from PRs, so I won't manually edit it. Let me run a clippy/build check on the format crate and verify the full format test suite passes.
Assistant
Clippy is clean. Let me test a couple more edge cases (lambda/closure args, inlinable last arg) by temporarily re-adding the example.
Assistant
All edge cases work. Let me remove the temporary example and do a final review of the diff.
Assistant
Let me run the full format spec tests one final time to confirm everything passes.
Assistant
Let me also run the lex tests to ensure the compiler-side multi-line interpolation detection is unaffected (I didn't touch it, but being thorough).
Assistant
Let me verify there are no leftover artifacts in the repo before submitting.
Assistant
The repository is clean with only my intended change. Let me do a final review of the change in context.
Assistant
There's a double blank line before
block. Let me fix that to keep consistent style.Assistant
Actually it's fine - there's only one blank line (line 264 is blank, line 265 is
pub(super) fn block). The display above looked like double but it's actually just one blank line. Good. Wait, the earlier sed output showed:} pub(super) fn blockThat's one blank line. Good. The earlier concern about double blank was from the diff display which showed an extra empty line, but that was just the diff context. Let me verify with cat -A to be sure there's not a double blank.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.