Fix last argument always being treated as greedy in suggestions #428
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.
Ever since the fix for #190 was merged (#414), all parsers would be treated as greedy if they were the last parser on the command, one of the argument parsers that heavily suffered from this was duration, here's how it looks like:
This is due to duration parser suggesting letters if the last char is not a letter, since the input was
5s
, it attempts to suggest [input] + "d" etc, leaving these weird suggestions.The change makes it so if there's an ambiguity about what to do with the last parser (ie: there's only one parser left, but there's more than one string left in the queue) it will let it get parsed, and observes what's left in the command queue after the parse. If the parser consumed all strings, then it's free to suggest the whole string with spaces, otherwise, it is understood that the parser is non-greedy, and the leftover text is not part of the command, and as such, should suggest nothing:
Tested with greedy arguments and seems to work just fine too.