Skip to content

refactor(ui): simplify copy-selection row ranges - #859

Open
benvinegar wants to merge 1 commit into
mainfrom
refactor/simplify-copy-selection-ranges
Open

refactor(ui): simplify copy-selection row ranges#859
benvinegar wants to merge 1 commit into
mainfrom
refactor/simplify-copy-selection-ranges

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Problem

buildCopySelectedRowKeys classified every intersecting row through four overlapping interval cases. Those branches all encoded the same two boundary questions, making wrapped-row selection behavior harder to verify than necessary.

Approach

  • replace the four-way interval classification with direct start/end boundary algebra;
  • keep the existing half-open row bounds and inclusive selection endpoints;
  • add exact table-driven coverage for unwrapped, wrapped, reverse-drag, and pinned-header boundaries.

This is a behavior-preserving maintenance refactor. It does not change clipboard rendering or selection interaction.

Cyclomatic complexity for buildCopySelectedRowKeys drops from 24 to 14.

Validation

Tested on Linux:

  • bun test src/ui/components/panes/copySelection.test.ts — 53 passed;
  • bun run typecheck;
  • bun run lint;
  • bunx oxfmt --check src/ui/components/panes/copySelection.ts src/ui/components/panes/copySelection.test.ts;
  • git diff --check main...HEAD.

An independent exhaustive probe compared the old and new formulas across 6,998 intersecting integer interval combinations with no mismatch. No visual evidence is included because rendered behavior is unchanged.

This PR description was generated by Pi using OpenAI GPT-5.6 Sol

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Aug 26, 2026 1:25pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This behavior-preserving refactor replaces overlapping row-interval branches with equivalent start/end boundary algebra.

  • Simplifies copy-selection range calculation for wrapped and unwrapped rows.
  • Adds exact table-driven coverage for boundary clipping, reverse drags, and pinned headers.
  • Adds an empty changeset for the maintenance-only change.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or quality issues identified.

The simplified comparisons preserve the old branch behavior for all intersecting interval relationships, including equality boundaries, wrapped rows, reverse drags, and pinned-header selections.

Important Files Changed

Filename Overview
src/ui/components/panes/copySelection.ts Replaces four exhaustive interval branches with mathematically equivalent boundary comparisons while preserving row-intersection behavior.
src/ui/components/panes/copySelection.test.ts Adds exact coverage for the interval relationships and drag directions affected by the refactor.
.changeset/simplify-copy-selection-ranges.md Records the behavior-preserving maintenance change without requesting a package release.

Reviews (1): Last reviewed commit: "refactor(ui): simplify copy selection ra..." | Re-trigger Greptile

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.

1 participant