Skip to content

Alt Shift selections do not accumulate - #45

Merged
janglad merged 3 commits into
mainfrom
fix/web-3962-pen-altshift-selections-back-do-not-accumulate
Sep 16, 2026
Merged

janglad merged 3 commits into
mainfrom
fix/web-3962-pen-altshift-selections-back-do-not-accumulate

Conversation

@janglad

@janglad janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes WEB-3962:

  • Preserve backward Alt+Shift selection anchors.
  • Allow keyboard selections to extend across multiple blocks.
  • Add regression tests.

Test plan

  • DOM test suite
  • Workspace build and typecheck
  • Lint and formatting

Note

Medium Risk
Changes keyboard selection sync and expanded-mode key handling, which can affect caret/selection behavior across blocks; scope is limited to DOM field-editor paths with new tests.

Overview
Fixes backward Alt+Shift word selections so repeated word-select shortcuts keep the same anchor and keep extending the focus, instead of resetting direction after each keypress.

syncEditorTextSelection now treats a DOM range as equivalent to the editor selection when min/max offsets match, so backward selections are not mistaken for a different range and re-applied via selectText in a way that flips anchor/focus.

Multi-block expanded contenteditable mode now runs the same keymap path as single-block editing (with Enter still deferred to beforeinput for multi-block ranges). That enables word selection and navigation commands—including Home with the visual line-edge measure—to work while a selection spans blocks. ensureLineEdgeMeasure is shared from contenteditableDomHelpers for both code paths.

Regression tests cover repeated Alt+Shift+ArrowLeft within a block, cross-block word extend, expanded-mode Enter/Home, and the line-edge seam before Home.

Reviewed by Cursor Bugbot for commit 5aed96e. Bugbot is set up for automated code reviews on this repo. Configure here.

This update preserves the backward keyboard selection direction across repeated word-selection commands and allows word selections to extend across multiple blocks. Key changes include:

- Updated selection validation logic in `syncEditorTextSelection` to ensure accurate range checks.
- Introduced new tests to verify the correct behavior of backward word selection across blocks.

These improvements aim to enhance user experience by providing more intuitive text selection capabilities.
@janglad

janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor 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.

Stale Bugbot comment from a previous run.

This update introduces the `ensureLineEdgeMeasure` function to improve line-edge measurement in the editor. Additionally, it modifies the handling of the Enter key to leave multi-block selections to the beforeinput event, ensuring more intuitive text editing behavior.

Key changes include:
- Added `ensureLineEdgeMeasure` function to `keyHandling.ts`.
- Updated `ExpandedContentEditableBackend` to call `ensureLineEdgeMeasure` before dispatching key events.
- Introduced tests to verify the new behavior for multi-block Enter key handling and line-edge measurement.

These enhancements aim to refine user experience during text editing and selection in the editor.
@janglad

janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor 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.

Stale Bugbot comment from a previous run.

This update introduces the `ensureLineEdgeMeasure` function to enhance line-edge measurement capabilities in the editor. The function is now properly imported and utilized in `expandedContentEditableBackend.ts`, while redundant imports in `keyHandling.ts` have been removed.

Key changes include:
- Added `ensureLineEdgeMeasure` to `contenteditableDomHelpers.ts`.
- Updated `expandedContentEditableBackend.ts` to import and use the new function.
- Cleaned up imports in `keyHandling.ts` for better code organization.

These modifications aim to improve the editor's functionality and maintainability.
@janglad

janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5aed96e. Configure here.

@janglad
janglad merged commit abc42e1 into main Sep 16, 2026
36 checks passed
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