Fix for handling multiple tab autocomplete attempts#62
Open
Vpet95 wants to merge 3 commits intoheapwolf:masterfrom
Open
Fix for handling multiple tab autocomplete attempts#62Vpet95 wants to merge 3 commits intoheapwolf:masterfrom
Vpet95 wants to merge 3 commits intoheapwolf:masterfrom
Conversation
added 3 commits
August 15, 2022 19:52
…t start at the beginning of the newly found list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
autoCompleteSearchTermallows users to cycle through the results of the current search, whilestrallows 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