Repository navigation
Return the formatted file for file-output formatters - #765
Merged
mehmetozguldev merged 1 commit intoOct 4, 2026
Merged
Conversation
format_with_generic returned the original content for any formatter whose outputMethod is not "stdout". Extensions that reformat a file in place therefore reported success while handing back unformatted text. Read the file back instead, which is what the file output method actually means. A missing file path now fails loudly, and a file that cannot be read falls back to the original content rather than failing the whole request. The TODO this replaces came from 1e321ac, which unified editor command execution but left the file branch unimplemented.
mehmetozguldev
self-requested a review
October 2, 2026 18:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Formatters configured with
outputMethod: "file"rewrite the file in place, butformat_with_genericnever read it back. It returned the originalcontentwhile reportingsuccess: true, so the user silently kept unformatted text with no error surfaced. This predates the agent-chat redesign: the branch came from commit1e321ac0("Unify editor command execution"), which left the TODO unimplemented.outputMethodis notstdoutfile_pathwas suppliedcontentwhen the file cannot be read, rather than failing the requestHow to test:
cargo test -p athas --bin athas -- commands::editor::formatreturns_file_contents_for_file_output_methodfails if theelsebranch is reverted tocontent.to_string(), since rustfmt rewrites the temp file while the response keeps returning the unformatted input.Screenshots:
Not applicable.
Validation
cargo check --workspace --all-targets— passcargo clippy --workspace --all-targets -- -D warnings— passcargo test --workspace --no-fail-fast— pass, 0 failurescargo fmt --check— this file is clean. Note the repo pins nightly inrust-toolchain.tomland CI runs nightly for fmt; on a stable toolchain the check reports unrelated pre-existing diffs incrates/ai,crates/runtime,crates/terminal,crates/toolingandcrates/wsl. None are from this change.Gap: the tests shell out to
rustfmtas the file formatter. That keeps the test honest end to end, but it does assumerustfmtis onPATHin CI, which the existingcargo fmt --checkgate already guarantees.