From db75c218de327f7a1c642b23a627efdbfc19c2c1 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 7 Oct 2022 18:57:26 -0400 Subject: [PATCH] fix(choose): selected bug when limit == 1 --- choose/command.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/choose/command.go b/choose/command.go index dea789f..a5b6a7e 100644 --- a/choose/command.go +++ b/choose/command.go @@ -60,9 +60,13 @@ func (o Options) Run() error { isSelected := hasSelectedItems && currentSelected < o.Limit && arrayContains(o.Selected, option) // If the option is selected then increment the current selected count. if isSelected { - currentSelected++ if o.Limit == 1 { + // When the user can choose only one option don't select the option but + // start with the cursor hovering over it. startingIndex = i + isSelected = false + } else { + currentSelected++ } }