-
Notifications
You must be signed in to change notification settings - Fork 15
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
Get span of each item #19
Comments
Sorry for my inattention to this repo. I happened to notice this when visiting the issue tracker due to another issue that was just opened. If you’re still interested, I’m willing to review PRs. Maybe this can be combined with the other two parsing feature requests (#9 and #13) into a more featureful lower-level API? (@fenhl, I’ll make sure not to do anything without your input, unless you’re not available. Of course, this can wait until after the holidays. I’m just responding today because that’s when I noticed this.) |
That sounds like a good idea. |
I honestly don't remember exactly why I needed this. It was probably for my crate clap-repl to detect the cursor position for auto complete, but it seems now auto complete is working even when cursor is in the middle of the line, so maybe this was a XY problem and I didn't really need this. |
I looked at my code and found that I worked around the problem by trimming the input to the cursor position. That is, to detect the word position of the cursor in this example:
We can parse the trimmed version using shlex:
and the number of tokens (in this case, 3) is the answer. Although my original problem is solved, I still think there is some utility in returning the spans in a more featureful parsing api, and most of the other parsing libraries have such a api. |
I need this to detect which item the cursor is in it. Would you accept a PR for this functionality?
The text was updated successfully, but these errors were encountered: