on main help sign in
fix(ui): add exit alias to the quit command
95e93e9Kieran Klukas
internal/ui/dialog/commands.go+1−1
@@ -524,7 +524,7 @@ func (c *Commands) defaultCommands() []*CommandItem {
524 commands = append(commands, NewCommandItem(c.com.Styles, "toggle_transparent", transparentLabel, "", ActionToggleTransparentBackground{}))
524 commands = append(commands, NewCommandItem(c.com.Styles, "toggle_transparent", transparentLabel, "", ActionToggleTransparentBackground{}))
525
525
526 commands = append(commands,
526 commands = append(commands,
527− NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}),
527+ NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}).WithAliases("exit"),
528 )
528 )
529
529
530 return commands
530 return commands
internal/ui/dialog/commands_item.go+13−1
@@ -1,6 +1,8 @@
1package dialog
1package dialog
2
2
3import (
3import (
4+ "strings"
5+
4 "github.com/charmbracelet/crush/internal/ui/styles"
6 "github.com/charmbracelet/crush/internal/ui/styles"
5 "github.com/sahilm/fuzzy"
7 "github.com/sahilm/fuzzy"
6)
8)
@@ -11,6 +13,7 @@ type CommandItem struct {
11 title string
13 title string
12 shortcut string
14 shortcut string
13 action Action
15 action Action
16+ aliases []string
14 t *styles.Styles
17 t *styles.Styles
15 m fuzzy.Match
18 m fuzzy.Match
16 cache map[int]string
19 cache map[int]string
@@ -30,9 +33,18 @@ func NewCommandItem(t *styles.Styles, id, title, shortcut string, action Action)
30 }
33 }
31}
34}
32
35
36+// WithAliases returns the CommandItem with the given aliases for filtering.
37+func (c *CommandItem) WithAliases(aliases ...string) *CommandItem {
38+ c.aliases = aliases
39+ return c
40+}
41+
33// Filter implements ListItem.
42// Filter implements ListItem.
34func (c *CommandItem) Filter() string {
43func (c *CommandItem) Filter() string {
44+ if len(c.aliases) == 0 {
45+ return c.title
46+ }
35− return c.title
47+ return c.title + " " + strings.Join(c.aliases, " ")
36}
48}
37
49
38// ID implements ListItem.
50// ID implements ListItem.