Skip to content

Commit

Permalink
feat(selection): unselected before quit (#41)
Browse files Browse the repository at this point in the history
Co-authored-by: zhiyang.wang <[email protected]>
  • Loading branch information
wangzhiy and zhiyang.wang authored Apr 18, 2023
1 parent 4e4288b commit 674bc37
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

if key.Matches(msg, s.Keymap.Quit) {
s.unselectAll()
return s, tea.Quit
}

Expand Down Expand Up @@ -473,6 +474,13 @@ func (s *Selection) selectAll() {
}
}

// unselectAll change all item to unSelected
func (s *Selection) unselectAll() {
for idx := range s.Choices {
delete(s.Selected, idx)
}
}

// flip all Selected
func (s *Selection) flip() {
for _, choice := range s.Choices {
Expand Down

0 comments on commit 674bc37

Please sign in to comment.