File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -314,11 +314,12 @@ protected function handleInput(): void
314314 $ this ->startDeleteProcess ($ dir );
315315 }
316316 } elseif ($ byte === 's ' ) {
317- $ this ->activeDir = $ count > 0 ? $ visibleDirs [$ this ->cursor ] : null ;
318317 $ this ->cycleSortMode ();
318+ $ this ->resetSelectionToTop ();
319319 $ this ->syncCursorState ($ this ->visibleDirs ());
320320 } elseif ($ byte === 'S ' ) {
321321 $ this ->toggleSortDirection ();
322+ $ this ->resetSelectionToTop ();
322323 $ this ->syncCursorState ($ this ->visibleDirs ());
323324 } elseif ($ byte === 'q ' || $ byte === "\x03" || $ byte === "\x04" ) {
324325 $ this ->running = false ;
@@ -439,6 +440,13 @@ protected function toggleSortDirection(): void
439440 $ this ->setSortDirection ($ this ->sortDirection () === 'asc ' ? 'desc ' : 'asc ' );
440441 }
441442
443+ protected function resetSelectionToTop (): void
444+ {
445+ $ this ->cursor = 0 ;
446+ $ this ->scrollOffset = 0 ;
447+ $ this ->activeDir = null ;
448+ }
449+
442450 /**
443451 * @return string[]
444452 */
You can’t perform that action at this time.
0 commit comments