Commit cf97b96
authored
refactor(coordinator): RowOperations migrates to selectedTabAndIndex + fix delete-row visual regression (#940)
* refactor(coordinator): migrate RowOperations to selectedTabAndIndex + fix invalidateCachesForUndoRedo regression
Two changes:
1. RowOperations migration. Six methods (addNewRow, deleteSelectedRows, duplicateSelectedRow, handleUndoResult, pasteRows, updateCellInTab) used the selectedTabIndex + bounds-check + tabs[index] pattern; now use selectedTabAndIndex which returns (tab, index) atomically. Three read-only methods (copySelectedRowsToClipboard, copySelectedRowsWithHeaders, copySelectedRowsAsJson) drop the index entirely and use selectedTab. undoInsertRow only needs the tabId so it uses selectedTab?.id. Behavior unchanged.
2. Bug fix discovered during RowOperations smoke test: pressing Delete on an existing row didn't show the red background until the user clicked another row. Phase D-b (PR #938) dropped the versionChanged branch in reloadAndSyncSelection, which used to reload visible rows on any changeManager.reloadVersion bump. invalidateCachesForUndoRedo cleared the displayCache and rebuilt the visualStateCache but never told NSTableView to re-query, so visible cell views kept rendering the pre-change state. Adding a reloadData(forRowIndexes: visibleRows, columnIndexes: allCols) call after the cache invalidation restores the lost behavior. Same root cause covers undo/redo of cell edits, deletes, and inserts.
* test+refactor: lock invalidateCachesForUndoRedo dispatch, tighten copy/undo paths
Two follow-ups to the review:
1. Read-only copy paths (copySelectedRowsToClipboard, copySelectedRowsWithHeaders, copySelectedRowsAsJson) and undoInsertRow now use selectedTabAndIndex instead of selectedTab. selectedTab has a fallback to tabs.first when selectedTabId is nil — the old selectedTabIndex pattern did not. Switching to selectedTabAndIndex (with _ for unused index) restores strict equivalence with the pre-refactor behavior. Closes the subtle init-transient divergence the review flagged.
2. New RowOperationsDispatchTests covers the dispatch wiring restored by this PR's bug fix:
- softDeleteDispatchesInvalidate: deleteSelectedRows on existing rows fires invalidateCachesForUndoRedo (the path that triggers the visible-rows reload). Without this, a future refactor could silently re-drop the reload (as Phase D-b accidentally did).
- physicalDeleteDispatchesDelta: deleting an inserted row fires applyDelta and bypasses invalidate — guards the branching in deleteSelectedRows so the two paths don't get tangled.1 parent ce570a9 commit cf97b96
3 files changed
Lines changed: 142 additions & 41 deletions
File tree
- TableProTests/Views/Main
- TablePro/Views
- Main/Extensions
- Results
Lines changed: 22 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 38 | + | |
| 39 | + | |
43 | 40 | | |
44 | 41 | | |
45 | | - | |
| 42 | + | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
| |||
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
85 | 80 | | |
86 | 81 | | |
87 | 82 | | |
| |||
110 | 105 | | |
111 | 106 | | |
112 | 107 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 108 | + | |
| 109 | + | |
117 | 110 | | |
118 | 111 | | |
119 | 112 | | |
| |||
135 | 128 | | |
136 | 129 | | |
137 | 130 | | |
138 | | - | |
139 | | - | |
| 131 | + | |
140 | 132 | | |
141 | | - | |
142 | 133 | | |
143 | 134 | | |
144 | 135 | | |
| |||
159 | 150 | | |
160 | 151 | | |
161 | 152 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 153 | + | |
166 | 154 | | |
167 | 155 | | |
168 | 156 | | |
| |||
171 | 159 | | |
172 | 160 | | |
173 | 161 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 162 | + | |
178 | 163 | | |
179 | 164 | | |
180 | 165 | | |
| |||
184 | 169 | | |
185 | 170 | | |
186 | 171 | | |
187 | | - | |
188 | | - | |
189 | | - | |
| 172 | + | |
190 | 173 | | |
191 | 174 | | |
192 | 175 | | |
| |||
202 | 185 | | |
203 | 186 | | |
204 | 187 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 188 | + | |
| 189 | + | |
209 | 190 | | |
210 | 191 | | |
211 | 192 | | |
| |||
226 | 207 | | |
227 | 208 | | |
228 | 209 | | |
229 | | - | |
230 | | - | |
| 210 | + | |
| 211 | + | |
231 | 212 | | |
232 | 213 | | |
233 | 214 | | |
234 | 215 | | |
235 | 216 | | |
236 | | - | |
237 | | - | |
| 217 | + | |
| 218 | + | |
238 | 219 | | |
239 | 220 | | |
240 | 221 | | |
241 | | - | |
| 222 | + | |
242 | 223 | | |
243 | 224 | | |
244 | 225 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
397 | 404 | | |
398 | 405 | | |
399 | 406 | | |
| |||
Lines changed: 113 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments