diff --git a/cmd/version.txt b/cmd/version.txt index 8bd6ba8..c006218 100644 --- a/cmd/version.txt +++ b/cmd/version.txt @@ -1 +1 @@ -0.7.5 +0.7.6 diff --git a/internal/ui/handler.go b/internal/ui/handler.go index 1bcd683..2932673 100644 --- a/internal/ui/handler.go +++ b/internal/ui/handler.go @@ -37,6 +37,16 @@ func (h *Handler) handle() { func sortEntries(entries []util.Entry) { slices.SortFunc(entries, func(a, b util.Entry) int { + if tahAcceptedIdentifier != "" { + if a.Identifier() == tahAcceptedIdentifier { + return -1 + } + + if b.Identifier() == tahAcceptedIdentifier { + return 1 + } + } + text := elements.input.Text() if text == "" { diff --git a/internal/ui/interactions.go b/internal/ui/interactions.go index ca8ae90..10e10fc 100644 --- a/internal/ui/interactions.go +++ b/internal/ui/interactions.go @@ -25,13 +25,15 @@ import ( ) var ( - activationEnabled bool - amKey uint - cmdAltModifier gdk.ModifierType - amModifier gdk.ModifierType - amLabel string - commands map[string]func() - singleModule modules.Workable + activationEnabled bool + amKey uint + cmdAltModifier gdk.ModifierType + amModifier gdk.ModifierType + amLabel string + commands map[string]func() + singleModule modules.Workable + tahSuggestionIdentifier string + tahAcceptedIdentifier string ) func setupCommands() { @@ -250,6 +252,9 @@ func handleGlobalKeysPressed(val uint, code uint, modifier gdk.ModifierType) boo return true case gdk.KEY_Tab: if elements.typeahead.Text() != "" { + tahAcceptedIdentifier = tahSuggestionIdentifier + tahSuggestionIdentifier = "" + elements.input.SetText(elements.typeahead.Text()) elements.input.SetPosition(-1) @@ -752,6 +757,8 @@ func processAsync(ctx context.Context, text string) { }) } + tahAcceptedIdentifier = "" + handler.mut.Unlock() if !layout.Window.Box.Search.Spinner.Hide { @@ -776,6 +783,7 @@ func setTypeahead(modules []modules.Workable) { for _, v := range tah { if strings.HasPrefix(v.Term, trimmed) { toSet = v.Term + tahSuggestionIdentifier = v.Identifier } }