Skip to content

fix(diffs): use current selection for selection action#859

Merged
necolas merged 1 commit into
beta-1.3from
fix-diffs-selection-jump
Jun 22, 2026
Merged

fix(diffs): use current selection for selection action#859
necolas merged 1 commit into
beta-1.3from
fix-diffs-selection-jump

Conversation

@necolas

@necolas necolas commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Steps to reproduce:

  1. Open edit mode with the selection action enabled.
  2. Drag to select several characters inside a word.
  3. Click the gutter lightning-bolt icon, then the wrap button.
  4. Only the first (or last) character is wrapped, not the whole selection.

The gutter icon is a cached DOM element reused across renders for the same line, but its click handler closed over the selection captured when the icon was first created. During a drag that is the first single-character selection (the first letter for a forward drag, the last for a backward drag), so the action ran against a stale range instead of the user's final selection.

Read the current primary selection at click time so the action always operates on what the user has selected. Add a regression test covering the forward and backward drag cases.

Steps to reproduce:
1. Open edit mode with the selection action enabled.
2. Drag to select several characters inside a word.
3. Click the gutter lightning-bolt icon, then the wrap button.
4. Only the first (or last) character is wrapped, not the
   whole selection.

The gutter icon is a cached DOM element reused across renders for
the same line, but its click handler closed over the selection
captured when the icon was first created. During a drag that is
the first single-character selection (the first letter for a
forward drag, the last for a backward drag), so the action ran
against a stale range instead of the user's final selection.

Read the current primary selection at click time so the action
always operates on what the user has selected. Add a regression
test covering the forward and backward drag cases.
@vercel

vercel Bot commented Jun 19, 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 Jun 19, 2026 8:08pm
pierre-docs-diffshub Ready Ready Preview Jun 19, 2026 8:08pm
pierre-docs-trees Ready Ready Preview Jun 19, 2026 8:08pm
pierrejs-diff-demo Ready Ready Preview Jun 19, 2026 8:08pm

Request Review

@ije ije left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!!!

@necolas necolas merged commit 20e4261 into beta-1.3 Jun 22, 2026
8 checks passed
@necolas necolas deleted the fix-diffs-selection-jump branch June 22, 2026 17:38
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