Prior to this PR, a user's input was taken into account only for the first autocompletion pass through; after which prompt-sync would fall back to cycling through the entire possible data set provided by the user, regardless of whether the initial search string yielded multiple possible autocomplete results.
Additionally, any subsequent autocomplete attempts would yield results from anywhere within the new result list, not the start.
How does this fix the problem?
This PR splits the responsibilities of the autocomplete search string and the main output string between two variables.
autoCompleteSearchTerm allows users to cycle through the results of the current search, while str allows current selection and terminal output to stay up-to-date as it did before.
Hitting any other key after the tab would clear the current search state.
What is this attempting to fix?
Prior to this PR, a user's input was taken into account only for the first autocompletion pass through; after which prompt-sync would fall back to cycling through the entire possible data set provided by the user, regardless of whether the initial search string yielded multiple possible autocomplete results.
Additionally, any subsequent autocomplete attempts would yield results from anywhere within the new result list, not the start.
How does this fix the problem?
This PR splits the responsibilities of the autocomplete search string and the main output string between two variables.
autoCompleteSearchTerm
allows users to cycle through the results of the current search, whilestr
allows current selection and terminal output to stay up-to-date as it did before.Hitting any other key after the tab would clear the current search state.
Testing / Example Case
Simple demo program to demonstrate the fix:
In either version, running the program and entering "a", followed by TAB would yield the string: "Apple".
Prior to the fix, subsequent TAB inputs would yield the following results:
After the fix, subsequent tab inputs yield all a-strings:
Demo
Before
After