Skip to content

Commit

Permalink
fix(filter): abort on ctrl+q
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 18, 2024
1 parent 3cec9b7 commit be9f836
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"strings"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
Expand Down Expand Up @@ -33,6 +34,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()
Expand Down Expand Up @@ -76,6 +79,7 @@ func (o Options) Run() error {
WithWidth(width).
WithShowHelp(o.ShowHelp).
WithTheme(theme).
WithKeyMap(keymap).
Run()
if err != nil && !errors.Is(err, huh.ErrTimeout) {
return err
Expand All @@ -100,6 +104,7 @@ func (o Options) Run() error {
).
WithWidth(width).
WithTheme(theme).
WithKeyMap(keymap).
WithShowHelp(o.ShowHelp).
Run()
if err != nil && !errors.Is(err, huh.ErrTimeout) {
Expand Down

0 comments on commit be9f836

Please sign in to comment.