Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: select all keybinding #639

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (o Options) Run() error {
theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix)
theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix)

keymap := huh.NewDefaultKeyMap()
keymap.MultiSelect.ToggleAll.SetKeys("a", "ctrl+a")

for _, s := range o.Selected {
for i, opt := range options {
if s == opt.Key || s == opt.Value {
Expand All @@ -52,15 +55,15 @@ func (o Options) Run() error {
}
}

if o.NoLimit {
o.Limit = len(o.Options)
}

width := max(widest(o.Options)+
max(lipgloss.Width(o.SelectedPrefix)+lipgloss.Width(o.UnselectedPrefix))+
lipgloss.Width(o.Cursor)+1, lipgloss.Width(o.Header)+widthBuffer)

if o.Limit > 1 {
if o.NoLimit {
o.Limit = 0
}

if o.Limit > 1 || o.NoLimit {
var choices []string

field := huh.NewMultiSelect[string]().
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/huh v0.5.2
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04
github.com/charmbracelet/lipgloss v0.12.1
github.com/charmbracelet/log v0.4.0
github.com/charmbracelet/x/ansi v0.1.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 h1:ye4X
github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105/go.mod h1:gw7FxN8J9u7IAlwc1ab1GnbfOMGExC9iI0e1t2SHs6I=
github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng=
github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps=
github.com/charmbracelet/huh v0.5.2 h1:ofeNkJ4iaFnzv46Njhx896DzLUe/j0L2QAf8znwzX4c=
github.com/charmbracelet/huh v0.5.2/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM=
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 h1:4gl2RNDqRh0x5vGO0EPKOLXH+iEyHwq+36KNeuQ1/YI=
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM=
github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs=
github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
Expand Down
Loading