Skip to content

Commit 2e9cf5d

Browse files
feat: reset sort highlight on change
1 parent 19e1eb5 commit 2e9cf5d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/Commands/Concerns/TuiCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
*/

0 commit comments

Comments
 (0)