[diffs/edit] Fix empty-new FileDiff edit - #1063
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5732c6a384
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| diff, | ||
| recomputeEmptyDocumentDiff(diff, this.options.parseDiffOptions) | ||
| ); | ||
| this.markEditSessionPass(diff); |
There was a problem hiding this comment.
Avoid dirtying attach-only empty sessions
When an editor is attached to a diff whose new file starts empty and is then detached without any user edit, this shim sets editSessionDirty. The detach path calls finishEditSessionForDiff, which recomputes through the edit pipeline and preserves the synthetic [''] addition line, so a previously deletion-only/empty-new diff keeps rendering a green blank addition row after editing ends. Only mark the session dirty after an actual document change, or restore the original zero-line addition shape on session exit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
fixed in 4aa6f2a, empty caret-host rows are now removed during session exit, with split and unified regression coverage.
| diff.additionLines[0] === '' && | ||
| result.code.additionLines[0] == null | ||
| ) { | ||
| result.code.additionLines[0] = createPlainAdditionLineElement(0, ''); |
There was a problem hiding this comment.
Preserve the real unified row index
When this fallback runs for an empty-new diff in unified mode with deleted lines, the synthetic row is created with the helper's default data-line-index of 0,0; because this initial render cache is not dirty, processDiffResult does not rewrite it to the actual unified/split indexes (for example 1,0 after one deletion row). VirtualizedFileDiff parses data-line-index for height deltas and scroll anchors, so the empty addition row can be measured/cached under the deletion row's index and corrupt virtualized layout; pass the current rendered indexes into the synthetic element instead.
Useful? React with 👍 / 👎.
Empty-new FileDiff now renders editable line 1 and supports caret placement in split and unified views.
Screen.Recording.2026-08-06.at.22.52.55.mov
↓
Screen.Recording.2026-08-06.at.22.51.49.mov