Repository navigation
fix: keep unsaved edits when another program writes the file (#81) - #110
Conversation
An external write to an open Markdown file replaced unsaved visual edits, saved the result and cleared the editor's undo history without asking. - Never replace a dirty document from the file watcher. Keep the local text and show one warning per conflict with Compare (read-only diff of the latest external revision) and Load Disk Version (explicit discard, undoable in the editor). - Number host updates and send the base revision with webview edits, saves and save snapshots. Text typed before a reload from disk is kept and the replaced disk revision is reported; text typed before Load Disk Version is discarded. - Hold external updates while edits are unsent, so a queued update can no longer overwrite typing or diverge from the host buffer. - Watch file creation as well as change, so atomic saves are detected. - Break notification link syntax in file names shown in warnings. Covered by provider unit tests, browser specs and a new installed-VSIX external-conflict suite. Documentation and translations are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 159f523f39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Non-blocking findings: - Apply a held external update once an edit leaves nothing new to send; Source mode input never starts the typing idle timer. - Hold the editor's first save while a conflict raised by text typed before a disk reload is unanswered. VS Code's newer-file check cannot see that case. Echo the buffer back after a stale edit so the editor and buffer converge. - Insert file names literally in warning, error and diff-title text. - Add native cases for Source mode with a keyboard save, late own-save notifications and the held save in the typing race. Quality of life: - Show a Changed on disk status bar item and add Binary Markdown: Resolve External Change, so a closed warning stays reachable. - Read the file again for Compare and Load Disk Version. - Replace fixed native-suite delays with observable events. - Use no-break spaces inside French guillemets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bring in the settings organization and build-tool audit patch from #109. Resolve CHANGELOG.md by keeping both Unreleased entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Load Disk Version read the conflict's retained revision twice: once for the buffer edit and again for the editor update. A write detected while the edit was applied changed that revision in between, so the editor showed the newer write while the buffer held the older one, and the older one was then saved over the newer file. Capture one revision for the buffer, editor and save. When a newer write arrives during the load, skip the save and report it as a new conflict. Reported by the Codex review on #110. Co-Authored-By: Claude Opus 5.5 <[email protected]>
VS Code 1.85, the minimum supported version, reports "The content of the file is newer" when a document changed on disk is saved, even when the buffer already equals the file. Load Disk Version therefore left the document dirty there; CI's vscode-minimum lane caught it. When the version to load is the file itself, revert the document instead: it reloads the buffer from disk and clears the dirty state without writing. Revert acts on the active editor, so it runs only after confirming the active tab shows this document, bringing this editor forward if needed. Otherwise, or when the version was already overwritten on disk, the previous write-and-save path remains. A write detected during that path is reported as a new conflict instead of being overwritten. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Scope re-audit complete at The VS Code 1.85 Load Disk Version concern is confirmed resolved on the final candidate. Validate VSIX build 186, attempt 1 tested merge commit The VS Code 1.85 log explicitly records:
The scope audit found one additional watcher-baseline defect, fixed in Two regressions cover a write of the previous baseline and a delayed notification of the newly loaded revision, including when Revert reads a newer write. The previous-baseline regression was observed failing before the fix. The follow-up changes only The complete 37-file scope audit against Local checks on the final head with Node 24.21.0: compilation passed; 467 unit tests passed, 0 failed, 19 skipped for optional converter/package prerequisites; lint 0 errors, 11 existing warnings; documentation and whitespace checks passed. Native/platform acceptance above comes from CI, not a new local installed-VSIX run. The PR remains open and has not been merged. |
Closes #81. Related: #11, which covers save infrastructure shared with this change. #11's queued-edit and native-save overlap protections are unchanged, and
save-correctnessstill passes.Problem
When another program wrote an open Markdown file that had unsaved visual edits, the file watcher replaced the document, saved it and cleared the editor's undo history. The local edits were lost with no prompt and no way to recover them.
Behavior after this change
Design
update.edit,saveand the native-save snapshot carry thebaserevision their text was edited from.updatemessages, and its bridge ignores the new arguments.$replacement patterns) and separated at](, so a crafted name can't render as a notification command link.Scope audit follow-up
A scope audit of the first commit found four non-blocking issues, now fixed:
$patterns in file names.It also suggested QoL items, now added: the status bar route, re-reading the file for Compare and Load, event-based native waits, and French typography. The audit's CI blocker, the
npm auditfailure, was fixed onmainin #109, which is merged here.The Codex review found that a write detected while Load Disk Version applied could leave the editor and buffer on different revisions, and then save the older one over the newer file. Commit
0b8b7f3uses one revision for the buffer, editor and save, and reports a mid-load write as a new conflict.The VS Code 1.85 compatibility fix in
e7dc70auses Revert when the requested revision is still on disk, with an active-document guard and the existing save fallback. The follow-up scope audit found that Revert did not refresh the watcher's known disk baseline;ef01cbbupdates it and invalidates older watcher reads, preventing missed external changes and false conflicts after loading.Verification
Head
ef01cbbc86c652e2e5c2c3ec5c2ab63943c25c79includesmainat225ce8687eb1a761705b7bdf4237ac2177acf5e7.689a10504231d461ea46355d961bb866373feb32: four native lanes (Windows, Ubuntu, macOS, and VS Code 1.85.0), all nine browser shards with zero retries, and the required VSIX validation gate.ef01cbb: full compilation passed; 467 unit tests passed, 0 failed, 19 skipped for optional converter/package prerequisites. Lint passed with 0 errors and 11 existing warnings. Documentation and whitespace checks passed. The new previous-baseline regression was observed failing before the fix.Limitations
🤖 Generated with Claude Code