refactor(datagrid): extract TableSelection value type#926
Merged
Conversation
…gTableView Replace four stored properties (focusedRow, focusedColumn, selectionAnchor, selectionPivot) with a single TableSelection struct. Centralized didSet computes reload indices for transitioning focus, eliminating per-property reload logic. Backward-compat accessors keep external call sites unchanged. Phase A of the data grid clean-architecture refactor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase A of the data grid clean-architecture refactor. Self-contained, low-risk: extracts the four cell-focus / range-selection ints from
KeyHandlingTableViewinto a singleTableSelectionvalue type.Why
KeyHandlingTableViewowned four loose stored properties (focusedRow,focusedColumn,selectionAnchor,selectionPivot) plus two separatedidSetblocks that each computed partial reload indices. The blocks were almost-but-not-quite redundant:focusedRow.didSetreloaded only the OLD row, relying on selection-change to redraw the new rowfocusedColumn.didSetreloaded BOTH columns at the current rowInconsistent enough to be subtle. Hard to test (state lives on a UIView).
What changed
TableSelection: Equatablevalue type (focusedRow, focusedColumn, anchor, pivot, plussetFocus,clearFocus,resetAnchor,clearAnchor,hasFocus)TableSelection.reloadIndexes(from:)returns the (rows, columns) IndexSet pair needing redraw on a transitionKeyHandlingTableViewholds oneselection: TableSelection; itsdidSetcallsreloadIndexesand reloadsselection(no churn at call sites)Tests
17 unit cases for
TableSelectioncovering: defaults, focus mutation, anchor/pivot lifecycle, equatable, and every transition path throughreloadIndexes(no change, anchor-only, initial focus, clearing focus, row change, column change, both change).Files
TablePro/Views/Results/TableSelection.swift(new)TablePro/Views/Results/KeyHandlingTableView.swift(state migration)TableProTests/Views/Results/TableSelectionTests.swift(new)TableProTests/Views/Main/Child/DataTabGridDelegateTests.swift(FakeRowDeltaApplier conforms to existinginvalidateCachesForUndoRedorequirement added in refactor(datagrid): interaction fixes, window UndoManager, multi-cell paste #924)Test plan