diff --git a/internal/ui/dialog/commands.go b/internal/ui/dialog/commands.go index 4ac1b1aa40a43914d9a20f941ede35853f1004ca..fd2fedf31ca267637e30700c69c2f1a973c7012c 100644 --- a/internal/ui/dialog/commands.go +++ b/internal/ui/dialog/commands.go @@ -524,7 +524,7 @@ func (c *Commands) defaultCommands() []*CommandItem { commands = append(commands, NewCommandItem(c.com.Styles, "toggle_transparent", transparentLabel, "", ActionToggleTransparentBackground{})) commands = append(commands, - NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}), + NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}).WithAliases("exit"), ) return commands diff --git a/internal/ui/dialog/commands_item.go b/internal/ui/dialog/commands_item.go index ba705d489ba6d2d6cc306e21eb86bb920ad0b3dc..a71229716d30876bc4e0a0d68dc45a2f27896745 100644 --- a/internal/ui/dialog/commands_item.go +++ b/internal/ui/dialog/commands_item.go @@ -1,6 +1,8 @@ package dialog import ( + "strings" + "github.com/charmbracelet/crush/internal/ui/styles" "github.com/sahilm/fuzzy" ) @@ -11,6 +13,7 @@ type CommandItem struct { title string shortcut string action Action + aliases []string t *styles.Styles m fuzzy.Match cache map[int]string @@ -30,9 +33,18 @@ func NewCommandItem(t *styles.Styles, id, title, shortcut string, action Action) } } +// WithAliases returns the CommandItem with the given aliases for filtering. +func (c *CommandItem) WithAliases(aliases ...string) *CommandItem { + c.aliases = aliases + return c +} + // Filter implements ListItem. func (c *CommandItem) Filter() string { - return c.title + if len(c.aliases) == 0 { + return c.title + } + return c.title + " " + strings.Join(c.aliases, " ") } // ID implements ListItem.