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

Since version 0.10 gum choose --no-limit selection of one element by Enter does not work #339

Closed
WoozyMasta opened this issue Apr 22, 2023 · 17 comments
Labels
bug Something isn't working cmd/choose

Comments

@WoozyMasta
Copy link

Since version 0.10 gum choose --no-limit selection of one element by Enter does not work

To Reproduce
in versions 0.7-0.9 when pressing Enter one element at a time it is selected, in version 0.10 nothing will be selected

0.7-0.9

> printf '%s\n' Foo Bar Baz | gum choose --no-limit; echo $?
Foo
0

0.10

> printf '%s\n' Foo Bar Baz | gum choose --no-limit; echo $?
0

Desktop:
Linux 5.15.0-50-generic x86_64 Ubuntu 22.04.2 LTS (Jammy Jellyfish)

@ajs256
Copy link

ajs256 commented Apr 24, 2023

Can confirm on macOS 13.3.1 with the built-in terminal.

@ajs256
Copy link

ajs256 commented Apr 24, 2023

It seems to also happen with gum filter, on version 0.9.0 as well.

@MikaelFangel
Copy link
Contributor

MikaelFangel commented Apr 25, 2023

The selection behaviour was changed by e6de774 referring to #140 (:

@ajs256
Copy link

ajs256 commented Apr 26, 2023

@MikaelFangel Okay, but how do you actually select multiple items now?

@MikaelFangel
Copy link
Contributor

@ajs256 You select multiple by pressing space.

screen-2023-04-26-07:54:09

@WoozyMasta
Copy link
Author

@MikaelFangel
But this is not obvious behavior, if I need only one element, why should I additionally select it before use it?

Before 0.10, it seems to me there was a more logical behavior

@MikaelFangel
Copy link
Contributor

MikaelFangel commented Apr 26, 2023

@WoozyMasta imo the problem with just selecting the highlighted one was that it didn't seem obvious that it would select it if I pressed enter. But I also hear you on the issue with the additional button press and that it is a breaking change.

However both functionalities are wanted and I'm not in a position to make the choice about this (:

@bdrnglm
Copy link

bdrnglm commented Apr 27, 2023

In my opinion, the current behavior is more "logical," as only the selected items are returned. If the user presses enter without selecting any item, the command should return none to signal that no items have been selected. Otherwise, it would be difficult to determine if any items were selected or not.

@WoozyMasta
Copy link
Author

The old behavior seems more obvious

It now returns an exit status of 0 and an empty response when I hover over the second element and press enter. The element was selected by the arrows, I just don't need to mark it because I only want one element.

Naturally, if I need to select several elements, I must select each one separately.

UX looks exactly like this, and this is exactly the problem that we are facing in the current version. It might be worth making a popup here to let you know that nothing is selected, but this is a much more complex implementation than just returning logic to select one item under the cursor.

I see solutions like this:

  • in case of empty choice return exit code not equal to 0
  • return the logic as it was, do not make breaking changes
  • return the logic as it was, make the new logic an option through the launch argument (I like this option)
  • give feedback to the user that he did not select anything

@bdrnglm
Copy link

bdrnglm commented May 17, 2023

I agree with you. Maybe we should keep it as is to prevent breaking scripts using older version, and make the actual behavior an option at launch for those who want it.

@alexn-s
Copy link

alexn-s commented May 23, 2023

@MikaelFangel kinda stupid question but when i try to select multiple (with space) it does not select the item but adds a space to the search query.

currently i cant select multiple

am i missing something?

example

"apple", "banana " | gum filter --no-limit

gum version: 0.10.0
env: windows powershell

@MikaelFangel
Copy link
Contributor

MikaelFangel commented May 23, 2023

@alexn-s actually this is not a stupid question. I seem to have trouble selecting multiple using the example provided by the README as well.

Edit:
Got it to function properly. Must have pressed it wrong when I tried 😅

@alexn-s
Copy link

alexn-s commented May 23, 2023

huh... thanks for letting me know

@maaslalani
Copy link
Contributor

@alexn-s In your example you would need to separate the options by newlines:

echo "apple\nbanana" | gum filter --no-limit

or:

echo "apple" >> choices.txt
echo "banana" >> choices.txt
cat choices.txt | gum filter --no-limit

To select, you can press ctrl+space or tab

@alexn-s
Copy link

alexn-s commented May 23, 2023

@maaslalani

comma works fine in powerhell. echo with newline does not work
tab works. did not try that

ctrl+space does not work

thanks for the help

@Justinzobel
Copy link

I just came across this from another issue to figure out how to select multiple items. If this information could be added to the README in the no-limit section it would improve the user experience.

@caarlos0
Copy link
Member

caarlos0 commented Dec 9, 2024

fixed on main!

thanks

@caarlos0 caarlos0 closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cmd/choose
Projects
None yet
Development

No branches or pull requests

8 participants