fix(filter): abort on ctrl+q (#721)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2024-12-03 11:40:24 -03:00 committed by GitHub
commit 63a3e8c8ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@ import (
"slices"
"strings"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
@ -35,6 +36,8 @@ func (o Options) Run() error {
}
theme := huh.ThemeCharm()
keymap := huh.NewDefaultKeyMap()
keymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "ctrl+q"))
options := huh.NewOptions(o.Options...)
theme.Focused.Base = lipgloss.NewStyle()
@ -84,6 +87,7 @@ func (o Options) Run() error {
WithWidth(width).
WithShowHelp(o.ShowHelp).
WithTheme(theme).
WithKeyMap(keymap).
WithTimeout(o.Timeout).
Run()
if err != nil {
@ -109,6 +113,7 @@ func (o Options) Run() error {
).
WithWidth(width).
WithTheme(theme).
WithKeyMap(keymap).
WithTimeout(o.Timeout).
WithShowHelp(o.ShowHelp).
Run()