allow initial query and select if there is exactly one match

This commit is contained in:
2026-03-03 23:30:08 +01:00
parent be1ecb0679
commit aa6a320f95
+15 -5
View File
@@ -91,11 +91,8 @@ func main() {
seshNames = append(seshNames, seshName) seshNames = append(seshNames, seshName)
} }
slices.Sort(seshNames) slices.Sort(seshNames)
i, err := fuzzyfinder.Find(
seshNames, options := []fuzzyfinder.Option{
func(i int) string {
return seshNames[i]
},
fuzzyfinder.WithPreviewWindow( fuzzyfinder.WithPreviewWindow(
func(i, width, height int) string { func(i, width, height int) string {
width = width/2 - 4 width = width/2 - 4
@@ -125,6 +122,19 @@ func main() {
return builder.String() return builder.String()
}, },
), ),
fuzzyfinder.WithSelectOne(),
}
if len(os.Args) > 1 {
options = append(options, fuzzyfinder.WithQuery(os.Args[1]))
}
i, err := fuzzyfinder.Find(
seshNames,
func(i int) string {
return seshNames[i]
},
options...,
) )
if err != nil { if err != nil {
return return