Skip to content

Commit 6472287

Browse files
committed
use min for slice indexing
1 parent 183693a commit 6472287

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

callbacks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (c *ClosestMatch) CB() Callback {
8989
}
9090

9191
if inp == "" { // first load or backspaced text
92-
topN = content[:c.MaxShown]
92+
topN = content[:min(len(content), c.MaxShown)]
9393
} else if !tab {
9494
// Only repopulate topN on non-tab entries
9595
topN = cm.ClosestN(strings.ToLower(inp), c.MaxShown)

0 commit comments

Comments
 (0)