Commit 26082d5
committed
Add scrolling support to branch selection dialog
Implements viewport-based scrolling for the create worktree dialog to
support browsing through large branch lists in small terminals.
Features:
- Viewport rendering with automatic scroll adjustment during navigation
- Visual scroll indicators ("▲ more above" / "▼ more below")
- Terminal resize detection with scroll position recalculation
- Minimum height validation (15 lines) with error messaging
- Selection always visible with 2-line margin for smooth scrolling
Technical changes:
- Added LineType enum to represent flattened line structure
- Added scroll state tracking (scroll_offset, last_known_height,
last_known_content_height)
- Implemented ensure_selected_visible() with proper indicator space
accounting
- Added comprehensive unit tests for scroll logic (8 new tests)
- Dialog auto-closes if terminal resized below minimum height
All 24 interactive tests pass. Supports repositories with 100+ branches
in terminals as small as 15 lines.1 parent bfccb6d commit 26082d5
File tree
5 files changed
+405
-21
lines changed- src/commands/interactive
5 files changed
+405
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
315 | 326 | | |
316 | 327 | | |
317 | 328 | | |
| |||
479 | 490 | | |
480 | 491 | | |
481 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
482 | 528 | | |
483 | 529 | | |
484 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 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 | + | |
3 | 33 | | |
4 | 34 | | |
5 | 35 | | |
| |||
28 | 58 | | |
29 | 59 | | |
30 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
31 | 74 | | |
32 | 75 | | |
33 | 76 | | |
| |||
107 | 150 | | |
108 | 151 | | |
109 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
110 | 191 | | |
111 | 192 | | |
112 | 193 | | |
| |||
115 | 196 | | |
116 | 197 | | |
117 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
118 | 203 | | |
119 | 204 | | |
120 | 205 | | |
| |||
149 | 234 | | |
150 | 235 | | |
151 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
152 | 284 | | |
153 | 285 | | |
154 | 286 | | |
| |||
161 | 293 | | |
162 | 294 | | |
163 | 295 | | |
| 296 | + | |
| 297 | + | |
164 | 298 | | |
165 | 299 | | |
166 | 300 | | |
| |||
173 | 307 | | |
174 | 308 | | |
175 | 309 | | |
| 310 | + | |
| 311 | + | |
176 | 312 | | |
177 | 313 | | |
178 | 314 | | |
| |||
0 commit comments