fix(app): select the last directory suggestion on first up arrow

This commit is contained in:
Dan Smolsky
2026-11-07 06:46:25 -05:00
Unverified
parent c72ce6cf82
commit c25316d7dc
2 changed files with 2 additions and 0 deletions
@@ -561,6 +561,7 @@ test("listing a folder passes the abort signal to the request", async () => {
test("wraps autocomplete keyboard navigation", () => {
expect(nextSuggestionIndex(-1, 1, 4)).toBe(0)
expect(nextSuggestionIndex(-1, -1, 4)).toBe(3)
expect(nextSuggestionIndex(3, 1, 4)).toBe(0)
expect(nextSuggestionIndex(0, -1, 4)).toBe(3)
expect(nextSuggestionIndex(0, 1, 0)).toBe(-1)
@@ -215,6 +215,7 @@ export function createPriorityTaskQueue<T>(concurrency: number) {
export function nextSuggestionIndex(current: number, delta: -1 | 1, count: number) {
if (count === 0) return -1
if (current < 0) return delta > 0 ? 0 : count - 1
return (current + delta + count) % count
}