Fix flags not tab-completing unless string is empty #460
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.
Currently trying to tab complete flag arguments only works if the string is empty, example:
/command -f
will work/command -f va
will not suggest "value" or anything else.This is because it attempts to
parse
the value of the flag instead of trying to suggest. I'm unsure as to why the if for directSuggestions only will enter if the value is empty, when given a size of 1 you know for sure it's going to be a direct-suggest. This if was last edited by myself in #428, where i added the size == 1 condition, it apparently seems like that ==1 should be the whole condition.Additionally, it solves #459 (tests were breaking otherwise).
I've removed the argument-pruning that was occurring in array types, as the tests broke the moment i modified the if. They were working out of pure luck, we remove all args except the last, then it attempts to parse the remaining
--
with the array parser (and nothing is consumed due to it being flag-yielding and the next param starting with-
) meaning it goes to the next argument (the flag) and ends up suggesting. That stopped working when i modified the if so that the last arg is always direct parsed, as we were still in the parent param (array) not the child (flag).Simply deleting the code that prunes the params solves the issue properly: when there's multiple params it'll parse them normally, they'll consume until the
-
due to flag-yielding, and the child node (flags) will take it from there.