Skip to content

Commit

Permalink
fix(choose): only show 'toggle all' if there's no limit
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Dec 5, 2024
1 parent 12d2ce0 commit abc197e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions choose/choose.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func defaultKeymap() keymap {
ToggleAll: key.NewBinding(
key.WithKeys("a", "A", "ctrl+a"),
key.WithHelp("ctrl+a", "select all"),
key.WithDisabled(),
),
Toggle: key.NewBinding(
key.WithKeys(" ", "tab", "x", "ctrl+@"),
Expand Down
8 changes: 7 additions & 1 deletion choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func (o Options) Run() error {
pager.InactiveDot = verySubduedStyle.Render("•")
pager.KeyMap = paginator.KeyMap{}
pager.Page = startingIndex / o.Height

km := defaultKeymap()
if o.NoLimit {
km.ToggleAll.SetEnabled(true)
}

// Disable Keybindings since we will control it ourselves.
tm, err := tea.NewProgram(model{
index: startingIndex,
Expand All @@ -115,7 +121,7 @@ func (o Options) Run() error {
timeout: o.Timeout,
showHelp: o.ShowHelp,
help: help.New(),
keymap: defaultKeymap(),
keymap: km,
}, tea.WithOutput(os.Stderr)).Run()
if err != nil {
return fmt.Errorf("failed to start tea program: %w", err)
Expand Down

0 comments on commit abc197e

Please sign in to comment.