Skip to content

Commit e28a3cf

Browse files
committed
minor: limit max suggestions
1 parent ff6b183 commit e28a3cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/hooks/usePathHistory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useCallback } from 'react'
22

33
const STORAGE_KEY = 'qbit-path-history'
44
const MAX_ENTRIES = 50
5+
const MAX_SUGGESTIONS = 5
56

67
function getHistory(): string[] {
78
try {
@@ -29,9 +30,9 @@ export function usePathHistory() {
2930

3031
const getSuggestions = useCallback((input: string): string[] => {
3132
const history = getHistory()
32-
if (!input) return history.slice(0, 5)
33+
if (!input) return history.slice(0, MAX_SUGGESTIONS)
3334
const lower = input.toLowerCase()
34-
return history.filter((p) => p.toLowerCase().includes(lower))
35+
return history.filter((p) => p.toLowerCase().includes(lower)).slice(0, MAX_SUGGESTIONS)
3536
}, [])
3637

3738
return { addPath, getSuggestions }

0 commit comments

Comments
 (0)