Skip to content

[diffs/edit] Fix surrogate-pair edit boundaries - #989

Merged
ije merged 2 commits into
beta-1.3from
ije/fix-surrogeta-pair
Jul 15, 2026
Merged

[diffs/edit] Fix surrogate-pair edit boundaries#989
ije merged 2 commits into
beta-1.3from
ije/fix-surrogeta-pair

Conversation

@ije

@ije ije commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Surrogate-pair edit boundaries (3) — edit range endpoints landing strictly inside a surrogate pair split the pair and corrupt the buffer instead of snapping to pair boundaries; affects insert-inside-a-pair and replaces starting or ending inside one.

Fixed surrogate-pair edit boundaries.

  • Inserts inside pairs snap before the pair; replacement endpoints widen outward.-
  • Lone surrogates remain editable.
  • Caret remapping uses the same normalized offsets.
  • Promoted all three regressions to passing tests and updated the known-bug count.

@vercel

vercel Bot commented Jul 15, 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 15, 2026 4:05pm
pierre-docs-diffshub Ready Ready Preview Jul 15, 2026 4:05pm
pierre-docs-trees Ready Ready Preview Jul 15, 2026 4:05pm
pierrejs-diff-demo Ready Ready Preview Jul 15, 2026 4:05pm

Request Review

@ije
ije requested review from amadeus, Copilot, fat and necolas and removed request for Copilot July 15, 2026 14:04
@ije

ije commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 00b93ca7cb

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

}
return this.applyResolvedEdits(
edits.map((edit) => this.#resolveEdit(edit)),
this.resolveEdits(edits),

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 Normalize resolved edits before applying them

Since the surrogate-pair widening is only done when TextEdit ranges go through resolveEdits, callers that already have UTF-16 offsets still bypass the fix via the exported applyResolvedEdits API; several editor selection helpers also use that path. For example, new TextDocument(..., '📚plans').applyResolvedEdits([{ start: 1, end: 1, text: 'a' }]) still inserts between the high and low surrogate and leaves lone surrogates in the buffer, so typing/paste-like flows that produce resolved offsets can still corrupt the document even though the known bug was removed.

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 3113d4f

@ije
ije merged commit 31ab338 into beta-1.3 Jul 15, 2026
8 checks passed
@ije
ije deleted the ije/fix-surrogeta-pair branch July 15, 2026 16:24
amadeus pushed a commit that referenced this pull request Jul 21, 2026
* Refactor edit resolution logic to improve surrogate pair handling

* fix codex
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