Skip to content

Name selection writes instead of inferring a selection's identity - #1323

Merged
nedtwigg merged 1 commit into
audit-selection-scrollbackfrom
simplify-selection-follow
Oct 21, 2026
Merged

nedtwigg merged 1 commit into
audit-selection-scrollbackfrom
simplify-selection-follow

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

A cleanup pass over #1280 and #1281.

setSelection used to work out whether a write was the same selection from its null-ness, plus a preserveProgramCopy flag. It now takes a write kind: replace, edit (a nudge), or follow (scroll, trim, or reflow).

  • A pending copy reports its result for an edited or followed selection, but not for a replaced one.
  • Only a follow keeps the program's copy offer.
  • A per-pane counter, bumped on clear and on replace, replaces the identity object. beginDrag no longer sets identity itself.

When older scrollback is trimmed, watchSelection now follows the selection without re-reading its baseline or disposing and re-registering markers on every shifted render. The markers have already moved with the content, so this saves that work while output streams into a full buffer.

  • The scroll marker no longer keeps a separate row; the row comes from the selection.
  • markRow puts the cursor-relative marker offset in one place, shared with the reflow anchor.
  • The followed span keeps the existing reflow anchor. A resize after the top row of its logical line is trimmed cancels the selection, as §3.4 requires.

Tests:

  • The trim test now checks that the markers survive. The newer-selection copy test now also covers a direct replace. Each fails when its fixed line is deleted.
  • The new lifecycle test uses COPY_FLASH_MS instead of a hard-coded 1500.

Not changed:

  • Unifying the scroll marker with anchorSelection. That would mean running followReflow's line walks on every render, and the two answer different questions.
  • A translate-only path for the copy editor's rebuild on each trim. It is more machinery than the saving justifies.
  • A shared deferred-clipboard test helper. The fixtures module is shared with stories and has no vi.

Validation: lib tsc -b, standalone tsc --noEmit, spec and Markdown lints, and the lib suite pass. The one exception is relay-origin.test.ts, which needs a built remote-lib-common in a fresh worktree and fails the same way on #1281's branch.

🤖 Generated with Claude Code

setSelection now says whether a write replaces, edits, or follows the
selection: only a replace starts a new one for a pending copy, and only a
follow keeps the program's offer. A counter bumped on clear or replace stands
in for the inferred identity object, so beginDrag no longer special-cases it.

The trim follow reuses the markers that already moved with the content
instead of rebuilding the baseline and every marker on each shifted render.
The scroll marker drops its redundant row, and markRow shares the
cursor-relative marker math with the reflow anchor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nedtwigg
nedtwigg added this pull request to stack #1322 October 21, 2026 15:56
@nedtwigg
nedtwigg merged commit 161d52b into main Oct 21, 2026
17 of 18 checks passed

This branch was successfully deployed

No deployments
hosted-preview — a7ebd175 Deployed Oct 21, 2026 by nedtwigg via deploy #1818
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