Skip to content

Explainer for Multi-Range Selection in Chromium#1311

Open
sambandaru wants to merge 2 commits intoMicrosoftEdge:mainfrom
sambandaru:multi-range-selection
Open

Explainer for Multi-Range Selection in Chromium#1311
sambandaru wants to merge 2 commits intoMicrosoftEdge:mainfrom
sambandaru:multi-range-selection

Conversation

@sambandaru
Copy link
Copy Markdown
Contributor

Adds an explainer proposing multi-range selection support in Chromium's Selection API. Chrome currently follows the W3C spec's single-range restriction (addRange() no-ops when a range exists), while Firefox has shipped multi-range for 20+ years. This proposes aligning Chromium with Firefox and updating the spec to allow addRange() to accumulate disjoint ranges, enabling Ctrl+Click discontinuous text selection.

```
"The quick brown fox jumps over the lazy dog"
^^^^^ ^^^ ^^^^
Range 1 Range 2 Range 3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Range 2 visually shows "jumps" although the explainer says to copy "fox"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixing

Range 1 Range 2 Range 3
```

User selects "quick", Ctrl+clicks "fox", Ctrl+clicks "lazy". Pressing Ctrl+C copies "quickfoxlazy".
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is having no separator a correct behavior. Firefox uses no separator but is it really what users want? Is there any way to track the exact ask?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There should be a delimiter - a space or a newline. Fixing.

### 6.2 Unchanged APIs

- `collapse()`, `collapseToStart()`, `collapseToEnd()`: collapse to single caret, removing all other ranges
- `extend()`: extends the focused (most recently added) range only
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens if extend() is called with a point that falls inside a different range? Does it merge? Does it error?

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