Skip to content

[diffs/editor] Fix diff re-render bug in edit mode#928

Open
ije wants to merge 6 commits into
beta-1.3from
editor/fix-diffs-edit
Open

[diffs/editor] Fix diff re-render bug in edit mode#928
ije wants to merge 6 commits into
beta-1.3from
editor/fix-diffs-edit

Conversation

@ije

@ije ije commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

reproduct steps:

  1. render diff in edit mode
  2. delete all lines of the new file (select all + delete)
  3. type 'a'
  4. stroke 'enter' to create a new line
  5. [bug] no new line rendered, the editor selection/caret disappear

@vercel

vercel Bot commented Jul 1, 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 Jul 3, 2026 8:45am
pierre-docs-diffshub Ready Ready Preview Jul 3, 2026 8:45am
pierre-docs-trees Ready Ready Preview Jul 3, 2026 8:45am
pierrejs-diff-demo Ready Ready Preview Jul 3, 2026 8:45am

Request Review

@ije ije requested a review from necolas July 1, 2026 16:01

@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: 4194855c94

ℹ️ 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".

Comment on lines +90 to +91
(hasOnlyBlankAdditionContents(additionLines) ||
hasTrailingEditorBlankLine(additionLines))

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 Restrict top-align recompute to blank additions

When an edit leaves the new document shorter than the old side and ending with a newline, additionLines now includes a trailing editor row such as ['kept\n', ''], so this condition routes contentful edits through recomputeTopAlignedAdditionDiff. That recompute parses a whitespace sentinel and only swaps the real additionLines back in, so unchanged lines that should remain context are instead rendered as top-aligned changes, corrupting ordinary edit-mode diffs such as deleting all but one matching line from a longer file. Keep this sentinel path limited to blank/delete-all additions or preserve the trailing caret row without replacing hunk metadata with sentinel hunks.

Useful? React with 👍 / 👎.

@necolas

necolas commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

this still leaves the latest new line stuck at the bottom of the diff

image

@ije

ije commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@necolas now does it work?

@necolas

necolas commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No still happens.

  1. Go to /playground
  2. Select all
  3. Type 'a'
  4. Press 'Enter'

New line is always at the bottom. Type something and it jumps up to the top

@ije

ije commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author
  1. Go to /playground
  2. Select all
  3. Type 'a'
  4. Press 'Enter'

@necolas thanks for the details. fixed in 8473a21. also fixed a phantom addition at the end of the docuemnt.

Screen.Recording.2026-07-03.at.16.32.41.mov

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