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

Fix duplicated multiselect #536

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alirezaarzehgar
Copy link
Contributor

@alirezaarzehgar alirezaarzehgar commented Jul 4, 2023

Description

Library can't handle duplicated option names cause it's design is based on checking option names not indexes. This PR change this behavior without breaking backward compatibility.

Scope

What is affected by this pull request?

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Related Issue

Fixes #535

To-Do Checklist

  • I tested my changes
  • I have commented every method that I created/changed
  • I updated the examples to fit with my changes
  • I have added tests for my newly created methods

`InteractiveSelectPrinter.Show()` always returns string and error.
User can't get index of selected option from `Options` array.
In some cases user need duplicated names. Current codebase will not
return good response for duplicated options.
Returning `selectedOption` attribute by another functions keep
backward-compatibility and solve this problem.

Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
In this test code will create a menu of a, b and c strings
then concurrently press key down two times and enter.
Then check `GetSelectedOption` return value with 2.

Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
- Check selectedOption value.
- Simulate human behavior and check result for normal usage.
- Check conflict on simultaneous use of both functions of setting default option.

Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #536 (f38f26f) into master (bc4dce5) will increase coverage by 0.38%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
+ Coverage   82.23%   82.61%   +0.38%     
==========================================
  Files          30       30              
  Lines        3501     3509       +8     
==========================================
+ Hits         2879     2899      +20     
+ Misses        564      558       -6     
+ Partials       58       52       -6     
Impacted Files Coverage Δ
interactive_multiselect_printer.go 58.80% <ø> (+2.57%) ⬆️
interactive_select_printer.go 57.14% <ø> (+4.06%) ⬆️

@MarvinJWendt
Copy link
Member

Hi @alirezaarzehgar, sorry for the late reply, I was on vacation.
Could you please update this PR, there was a change in the latest release that fixed a bug in select and multiselect on Windows. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library check and uncheck all of duplicated option names
2 participants