Commit 424bab4
committed
Add regression tests then fix fifth round of Copilot review comments
Tests added first (src/render.test.ts) as regression guards for the three
tui.ts-level state bugs — they exercise the pure functions involved and
document the correct behavior that the tui.ts fixes must preserve:
- isCursorVisible: stale scrollOffset > cursor (result of filter shrinking
rows without clamping scrollOffset) always returns false, confirming the
cursor is above the viewport and scrollOffset must be clamped
- buildRows + isCursorVisible: invalid regex after toggle produces 0 rows;
cursor at former position is out-of-range and must be re-clamped to 0
(Math.min(cursor, Math.max(0, rows.length - 1)))
- renderGroups: sticky repo header (\u25b2) is NOT shown when cursor is on a repo
row even when scrollOffset > 0 (only shown on extract rows whose repo row
has scrolled above the viewport)
Fixes (src/tui.ts):
1. stickyHeaderLines condition in getViewportHeight(): change
\`scrollOffset > 0 ? 1 : 0\` to \`scrollOffset > 0 && cursor >= scrollOffset ? 1 : 0\`
so the viewport is only shrunk by one when a sticky header will actually
be rendered by renderGroups, preventing premature scroll-stop on repo rows.
2. scrollOffset not clamped after filter reduces rows: add
\`scrollOffset = Math.min(scrollOffset, cursor)\` after cursor clamping in
Ctrl+W/Alt+Backspace, Backspace, Del, and printable-char (paste) handlers.
Without this, a previously-scrolled viewport could remain beyond the end
of the shrunken row list, producing an empty groups area with no recovery.
3. Tab toggle (filterRegex) did not rebuild rows or clamp cursor/scrollOffset:
after \`filterRegex = !filterRegex\`, now calls buildRows and applies the
same clamping as all other filter-state-changing handlers.
See PR #651 parent aecd617 commit 424bab4
2 files changed
Lines changed: 87 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
424 | 443 | | |
425 | 444 | | |
426 | 445 | | |
| |||
593 | 612 | | |
594 | 613 | | |
595 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
596 | 636 | | |
597 | 637 | | |
598 | 638 | | |
| |||
1061 | 1101 | | |
1062 | 1102 | | |
1063 | 1103 | | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
1064 | 1132 | | |
1065 | 1133 | | |
1066 | 1134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
178 | | - | |
| 181 | + | |
| 182 | + | |
179 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
203 | 210 | | |
204 | 211 | | |
205 | 212 | | |
| 213 | + | |
206 | 214 | | |
207 | 215 | | |
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
211 | | - | |
212 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
213 | 222 | | |
214 | 223 | | |
215 | 224 | | |
216 | 225 | | |
217 | | - | |
218 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
219 | 229 | | |
220 | 230 | | |
221 | 231 | | |
| |||
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
| 256 | + | |
246 | 257 | | |
247 | 258 | | |
248 | 259 | | |
| |||
0 commit comments