Skip to content

Commit

Permalink
fix(filter): hide toggle help if limit is 1
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Dec 6, 2024
1 parent 2061cab commit f3d3b86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion filter/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ func (o Options) Run() error {
matches = matchAll(o.Options)
}

km := defaultKeymap()

if o.NoLimit {
o.Limit = len(o.Options)
}
if o.NoLimit || o.Limit > 1 {
km.Toggle.SetEnabled(true)
km.ToggleAndPrevious.SetEnabled(true)
km.ToggleAndNext.SetEnabled(true)
}

p := tea.NewProgram(model{
choices: o.Options,
Expand Down Expand Up @@ -98,7 +105,7 @@ func (o Options) Run() error {
sort: o.Sort && o.FuzzySort,
strict: o.Strict,
showHelp: o.ShowHelp,
keymap: defaultKeymap(),
keymap: km,
help: help.New(),
}, options...)

Expand Down
3 changes: 3 additions & 0 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ func defaultKeymap() keymap {
ToggleAndNext: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "toggle"),
key.WithDisabled(),
),
ToggleAndPrevious: key.NewBinding(
key.WithKeys("shift+tab"),
key.WithHelp("shift+tab", "toggle"),
key.WithDisabled(),
),
Toggle: key.NewBinding(
key.WithKeys("ctrl+@"),
key.WithHelp("ctrl+@", "toggle"),
key.WithDisabled(),
),
Abort: key.NewBinding(
key.WithKeys("ctrl+c", "esc"),
Expand Down

0 comments on commit f3d3b86

Please sign in to comment.