Skip to content

[diffs/edit] Fix empty-new FileDiff edit - #1063

Open
ije wants to merge 2 commits into
mainfrom
ije/fix-empty-new-diffs-edit
Open

[diffs/edit] Fix empty-new FileDiff edit#1063
ije wants to merge 2 commits into
mainfrom
ije/fix-empty-new-diffs-edit

Conversation

@ije

@ije ije commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

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

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Aug 6, 2026 3:29pm
pierre-docs-diffshub Ready Ready Preview Aug 6, 2026 3:29pm
pierre-docs-trees Ready Ready Preview Aug 6, 2026 3:29pm
pierrejs-diff-demo Ready Ready Preview Aug 6, 2026 3:29pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, '');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 4aa6f2a

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.

1 participant