Skip to content

fix(editor): quit after pending format save - #373

Merged
fcoury-oai merged 4 commits into
mainfrom
fcoury/wq-format-on-save
Oct 9, 2026
Merged

fcoury-oai merged 4 commits into
mainfrom
fcoury/wq-format-on-save

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

A modified buffer using asynchronous format-on-save is still dirty when the :wq command immediately reaches its quit step, so Red saves the file later but remains open.

This change defers the quit while the current buffer is the only dirty buffer and its format-save is pending. A successful save completes the quit after background processing; failed saves, conflicts, or newly dirty buffers cancel it. The same completion handling applies to the interactive and detached editor paths.

How to Test

  1. Open a Rust file with format-on-save enabled, modify it, and run :wq.
    Expected: Red remains open while formatting is pending, then saves and exits after formatting completes.
  2. While the format-save is pending, modify the file externally.
    Expected: Red preserves the external file, keeps the local buffer open and dirty with a conflict, and does not exit.

Targeted coverage:

  • cargo test --lib wq_ --locked
  • cargo test --lib deferred_quit_is_cancelled_when_another_buffer_becomes_dirty --locked
  • cargo test --lib format_on_save_ --locked

@fcoury

fcoury commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@fcoury-oai
fcoury-oai merged commit e7a976e into main Oct 9, 2026
15 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/wq-format-on-save branch October 9, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants