-
Notifications
You must be signed in to change notification settings - Fork 336
Replace the cursor index within the completing word parameter of custom-completion closures with a String
completion prefix parameter
#770
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
Conversation
b9565bb
to
936e5fa
Compare
@natecook1000 @rauhul I also have a PR for #555 (supporting Please don't release a new version of Swift Argument Parser without checking with me first, because I might have other useful submissions queued up. Obviously, if I don't respond in a timely manner, go ahead & release new versions whenever you want, but if you could check with me first, I'd appreciate it, and users might get more functionality in the new release. Most importantly, if I realize that a new interface is suboptimal, it should be cleaned up ASAP before being officially released so it won't need to be maintained indefinitely, and so it won't be unpleasant for users. Thanks again. |
936e5fa
to
87d6faf
Compare
@rgoldberg This change makes sense, since the conversion from
...then the parameters passed to the custom completion closure would be as if it were called like: complete(["example", "--foo", "1", "--bar", "2", "baz", "bizzle"], 5, "b") Is that right? |
completingArgument.prefix( | ||
upTo: completingArgument.index( | ||
completingArgument.startIndex, | ||
offsetBy: cursorIndexWithinCompletingArgument | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a prefix overload that just takes the count of elements to include, so this can be simplified to .prefix(cursorIndexWithinCompletingArgument)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the PR now. I'm still new to Swift, so my API knowledge is limited. I didn't even realize how verbose it is to get substrings in Swift. Thanks for pointing this out. All similar tips will be greatly appreciated, as it will produce much nicer code & get me up to speed much faster. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natecook1000 Pushed the fix. Thanks again for the tip.
@natecook1000 My zsh cursor is always displayed between characters, not on them. Maybe you can switch cursor modes, but for the cursor in-between character mode, it would be between the Thanks for looking into this. |
…om-completion closures with a `String` `completionPrefix` parameter. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
5b3a864
to
f5ebfb5
Compare
@swift-ci Please test |
The failing API breakage check should be OK because the replaced API was never released in a new version. |
@rgoldberg We're on the same page! The default cursor indicator for me is a block, even though I think of that as the cursor for overwrite mode (though I can't remember what platform that was on). In any case, you're describing what I meant to. And exactly, merging over the API breakage check. |
Replace the cursor index within the completing word parameter of custom-completion closures with a
String
completion prefix parameter.Resolve #769
@natecook1000 @rauhul I think that this is an urgent improvement.
The Swift substring API is exceedingly verbose, and this will make using custom completions much easier.
We don't want to release the current API with the 2 indices to users because then it will need to be supported indefinitely, despite being suboptimal.
Checklist