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

Library check and uncheck all of duplicated option names #535

Open
alirezaarzehgar opened this issue Jul 4, 2023 · 1 comment · May be fixed by #536
Open

Library check and uncheck all of duplicated option names #535

alirezaarzehgar opened this issue Jul 4, 2023 · 1 comment · May be fixed by #536
Labels
bug Something isn't working

Comments

@alirezaarzehgar
Copy link
Contributor

Multiselect shouldn't behave like this. It should return separate results for each option.

Re produce bug:

func TestInteractiveMultiselectPrinter_Show_Duplicated(t *testing.T) {
	go func() {
		keyboard.SimulateKeyPress(keys.Enter)
		keyboard.SimulateKeyPress(keys.Down)
		keyboard.SimulateKeyPress(keys.Down)
		keyboard.SimulateKeyPress(keys.Enter)
		keyboard.SimulateKeyPress(keys.Down)
		keyboard.SimulateKeyPress(keys.Down)
		keyboard.SimulateKeyPress(keys.Enter)
		keyboard.SimulateKeyPress(keys.Tab)
	}()
	r, _ := pterm.DefaultInteractiveMultiselect.
		WithOptions([]string{"a", "a", "a", "a", "a", "a", "a", "a", "a"}).
		Show()
	testza.AssertEqual(t, []string{"a", "a", "a"}, r)
}

result:

=== RUN   TestInteractiveMultiselectPrinter_Show_Duplicated
Please select your options: 
  > a

    interactive_multiselect_printer_test.go:109: 
        
           1| Two objects that should be equal, are not equal.
           2| 
           3| Expected:
           4| ([]string) (len=3 cap=3) {
           5|  (string) (len=1) "a",
           6|  (string) (len=1) "a",
           7|  (string) (len=1) "a"
           8| }
           9| 
          10| Actual:
          11| ([]string) (len=1 cap=1) {
          12|  (string) (len=1) "a"
          13| }
          14| 
          15| Difference:
          16| (1. -) ([]string) (len=3 cap=3) {
          17| (2. -)  (string) (len=1) "a",
          18| (3. -)  (string) (len=1) "a",
          19| (1. +) ([]string) (len=1 cap=1) {
          20| (2. #)  (string) (len=1) "a"
          21| (3. #) }
        
        
--- FAIL: TestInteractiveMultiselectPrinter_Show_Duplicated (0.00s)
@alirezaarzehgar alirezaarzehgar added the bug Something isn't working label Jul 4, 2023
@alirezaarzehgar alirezaarzehgar linked a pull request Jul 4, 2023 that will close this issue
8 tasks
@MarvinJWendt
Copy link
Member

Yes makes sense, I think we just never really considered having the same options multiple times, but I agree that there might be some use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants