From aa6a320f954bfaf90e192508e6c6a519db4ea82f Mon Sep 17 00:00:00 2001 From: Ivar Fatland Date: Tue, 3 Mar 2026 23:30:08 +0100 Subject: [PATCH] allow initial query and select if there is exactly one match --- sesh/main.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sesh/main.go b/sesh/main.go index 9e1bbff..a994c38 100644 --- a/sesh/main.go +++ b/sesh/main.go @@ -91,11 +91,8 @@ func main() { seshNames = append(seshNames, seshName) } slices.Sort(seshNames) - i, err := fuzzyfinder.Find( - seshNames, - func(i int) string { - return seshNames[i] - }, + + options := []fuzzyfinder.Option{ fuzzyfinder.WithPreviewWindow( func(i, width, height int) string { width = width/2 - 4 @@ -125,6 +122,19 @@ func main() { 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 { return