We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23d8605 commit 02e4d05Copy full SHA for 02e4d05
callbacks.go
@@ -83,6 +83,11 @@ func (c *ClosestMatch) CB() Callback {
83
}
84
85
86
+ // When content is empty, don't show anything but the prompt
87
+ if len(content) == 0 {
88
+ return ""
89
+ }
90
+
91
if inp == "" { // first load or backspaced text
92
topN = content[:c.MaxShown]
93
} else if !tab {
examples/closestmatch_empty.go
@@ -0,0 +1,21 @@
1
+package main
2
3
+import (
4
+ "fmt"
5
6
+ "github.com/coxley/rtprompt"
7
+)
8
9
+func main() {
10
+ issues := map[string]string{}
11
+ var selected string
12
+ cb := rtprompt.ClosestMatch{
13
+ Data: issues,
14
+ OnSelect: func(s string) { selected = s },
15
+ MaxShown: 7,
16
+ ShowInstructions: true,
17
18
+ prompt := rtprompt.New("Summary: ", cb.CB())
19
+ prompt.Wait()
20
+ fmt.Printf("Woohoo! You selected: %s\n", selected)
21
+}
0 commit comments