mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
fix(app): select the last directory suggestion on first up arrow
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user