Skip to content

[diffs/edit] Add Alt/Option-drag column and rectangular selections - #1071

Open
ije wants to merge 3 commits into
mainfrom
ije/add-altdrag-multicursors
Open

[diffs/edit] Add Alt/Option-drag column and rectangular selections#1071
ije wants to merge 3 commits into
mainfrom
ije/add-altdrag-multicursors

Conversation

@ije

@ije ije commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Add Alt/Option-drag support for column-aligned and rectangular multi-selections.

Screen.Recording.2026-08-11.at.01.11.17.mov

@vercel

vercel Bot commented Aug 10, 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 10, 2026 6:06pm
pierre-docs-diffshub Ready Ready Preview Aug 10, 2026 6:06pm
pierre-docs-trees Ready Ready Preview Aug 10, 2026 6:06pm
pierrejs-diff-demo Ready Ready Preview Aug 10, 2026 6:06pm

Request Review

@ije

ije commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

@codex 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: 648ce794b4

ℹ️ 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 +4182 to +4186
const characterDelta =
characterDeltaRaw < 0
? -Math.round(-characterDeltaRaw)
: Math.round(characterDeltaRaw);
const focusCharacter = Math.max(0, anchor.character + characterDelta);

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 Snap Alt-drag offsets to grapheme boundaries

When Alt/Option-drag synthesizes focusCharacter from the pointer delta, it stores that raw UTF-16 offset directly in every generated selection. For lines containing emoji or combining-character graphemes, the rounded offset can land inside a grapheme; subsequent typing, delete, copy/cut, or replacement uses textDocument.offsetAt() on that unsnapped position and can split/corrupt the character. The vertical cursor path already snaps real landings out of graphemes, so this rectangular-selection path should do the same per affected line before calling #updateSelections.

Useful? React with 👍 / 👎.

@ije ije Aug 10, 2026

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.

Alt-drag now snaps both synthesized endpoints per line before creating selections, using the shared grapheme-boundary helper.

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