fix(diffs): Refresh reshaped split edits safely#910
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
💡 Codex Reviewpierre/packages/diffs/src/components/FileDiff.ts Line 1093 in 4c61db5 In split edit mode, when a user edits an added line back to the old-side text (or otherwise causes hunks to merge/split), pierre/packages/diffs/src/components/FileDiff.ts Lines 1007 to 1008 in 4c61db5 If an editable diff changes files or unmounts while ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Still working on this... |
|
@necolas #878 will ensure the cacheKey with the file name if it's not provided. we better should not add workarounds for the layout/options update. in further update, we need to cache TextDocuments using the cacheKey. so when switching file the undo stack remains. i also updated the playground/home apps in #878, please take a look |
In a split editable diff, change an added line back to the old-side text. The hunk can disappear or change shape, but the editor still used the split fast-refresh path, which only patches existing row attributes and leaves stale added or deleted rows in the DOM. Detect when recomputing content hunks changes the rendered hunk shape and use a full refresh for that case, clearing empty columns when a hunk disappears. Also guard async editor sync continuations so a highlighter promise from an older render cannot resync a detached or replaced editor.
80bf48b to
2a374c9
Compare
Fixes split-diff edit-mode rerendering issues surfaced by the Codex review on this branch.
Reproduction
/playgroundwith Edit mode).Before this change the editor stayed on the split fast-refresh path, which only patches row attributes — leaving stale added/deleted rows in the DOM.
Changes
fastRefreshDiffViewself-escalates to a full rebuild when a column's rendered row count diverges, instead of silently leaving stale rows.getDiffRenderShapeKey(the fast-vs-full gate) and add regression coverage: split reshape that removes a hunk, a same-split-count reshape, and fast-path reachability.Scope note
Rebased to drop the "preserve editor history across layout toggles" commit — that workaround is being handled via the cacheKey approach in #878. This PR is now only the split-reshape / async-sync correctness fix.