Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 9ac58f3

Browse files
committed
fix #11, add word len control to start search, cache only non empty data
1 parent 6660840 commit 9ac58f3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ func getFromCache(word string) []prompt.Suggest {
192192
completer, found := memoryCache.Get(cacheKey)
193193
if !found {
194194
completer = imageFetchCompleter(word, 10)
195-
memoryCache.Set(cacheKey, completer, cache.DefaultExpiration)
195+
if len(completer.([]prompt.Suggest)) > 0 {
196+
memoryCache.Set(cacheKey, completer, cache.DefaultExpiration)
197+
}
196198
}
197199
return completer.([]prompt.Suggest)
198200
}
@@ -217,6 +219,15 @@ func completer(d prompt.Document) []prompt.Suggest {
217219
}
218220

219221
if command == "pull" {
222+
223+
if len(strings.Split(d.Text, " ")) > 2 {
224+
return []prompt.Suggest{}
225+
}
226+
227+
if len(word) < 3 {
228+
return []prompt.Suggest{}
229+
}
230+
220231
if word != command {
221232
return getFromCache(word)
222233
}

0 commit comments

Comments
 (0)