Skip to content

Preserve selection direction across editor edits - #390

Merged
jserv merged 1 commit into
sysprog21:mainfrom
itisJoshuaTseng:preserve-editor-selection-direction
Oct 21, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
itisJoshuaTseng:preserve-editor-selection-direction

Conversation

@itisJoshuaTseng

@itisJoshuaTseng itisJoshuaTseng commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Preserve the selection direction across indentation, outdentation, and comment toggling so Shift+ArrowRight continues adjusting the original active end. Restore the direction for noncollapsed ranges in both shared edit paths, including edits that leave the text unchanged, while retaining collapsed-caret behavior and native undo.

Add browser regressions for forward and backward selections, subsequent selection adjustment, comment removal, one-step undo, and replacement with a collapsed caret. The eight direction cases fail before the fix.

Validation:

  • Both affected browser suites: 52 passed, no failures or skips.
  • RUST_TEST_THREADS=2 ./scripts/test.sh: passed; 1,738 Rust tests passed (21 ignored), 1,289 static Node tests and 3 server-backed Node tests passed, and 49 hook checks passed.
  • Visible Chrome 155 comparison: a backward selection of ary becomes aryx after Tab and Shift+ArrowRight on the original code, and correctly shrinks to ry with the fix.
  • make build: passed.

The initial full gate encountered a signal-terminated CLI child process; the isolated retest and complete run with reduced Rust test concurrency passed. Optional commentflow, ruff, shfmt, cargo-audit, actionlint, and shellcheck lanes were unavailable locally. The Linux-only Clang-fetch Python case was skipped on macOS.

Closes #385


Summary by cubic

Preserves the selection direction across indentation, outdentation, and comment toggling so Shift+ArrowRight keeps adjusting from the original active end. The direction is restored for noncollapsed ranges in both shared edit paths, including edits that leave the text unchanged; collapsed selections drop the previous direction and native undo behavior stays the same. Closes #385.

  • Adds browser regressions for forward and backward selections across Tab, Shift+Tab, and comment toggles, plus an Enter replacement that checks a collapsed caret no longer reports the replaced direction.

Written for commit 92213a7. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv
jserv force-pushed the preserve-editor-selection-direction branch 2 times, most recently from 71c7019 to a258cd0 Compare October 20, 2026 15:44
Comment thread tests/browser/editor-pipeline.test.js Outdated
@jserv
jserv requested review from ColtenOuO and alanhc October 21, 2026 00:48

@ColtenOuO ColtenOuO 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, but please squash your commits.

Editor commands lose the candidate's active selection end when they
restore a range after editing. Keep its original direction so later
Shift+Arrow adjustments continue from the same end, including when
outdenting leaves the text unchanged.

Cover both directions, comment toggles, collapsed replacement, and
native undo in browser regressions. Accept either none or forward for
the collapsed caret, which Chromium reports differently across
platforms. The eight direction cases fail before the fix.

Closes sysprog21#385
@itisJoshuaTseng
itisJoshuaTseng force-pushed the preserve-editor-selection-direction branch from 1a2b296 to 92213a7 Compare October 21, 2026 06:38
@jserv
jserv merged commit d467174 into sysprog21:main Oct 21, 2026
10 checks passed
@jserv

jserv commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Thank @itisJoshuaTseng for contributing!

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.

Editor edits lose backward selection direction

3 participants