pterm / pterm/pterm

Library check and uncheck all of duplicated option names

Open
#535 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
5.5k
Forks
221
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TestInteractiveMultiselectPrinter_Show_Duplicated in interactive_multiselect_printer_test.go and follow the DefaultInteractiveMultiselect.WithOptions(...).Show() entry point. Reproduce the duplicate-option selection, then confirm the test returns three separate "a" results rather than one and passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.