-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: question chain api #19828
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
base: master
Are you sure you want to change the base?
feat: question chain api #19828
Conversation
crates/ide-db/src/source_change.rs
Outdated
/// A list of choice groups. Each inner tuple's first string is title, second vector represents a set of options | ||
/// from which the user can make one selection. | ||
/// For example, `choice_options[0]` might be `["Question 1", ["Option A", "Option B"]]` and | ||
/// `choices[1]` might be `["Question 2", ["Setting X", "Setting Y"]]`. |
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.
Shouldn't this be choice_options[1]
instead of choices[1]
?
@@ -202,6 +203,45 @@ impl Assists { | |||
self.add_impl(Some(group), id, label.into(), target, &mut |it| f.take().unwrap()(it)) | |||
} | |||
|
|||
/// Give user multiple choices, user's choice will be passed to `f` as a list of indices. |
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 once again got a bit confused with the distinction between a multiple choice question and many consecutive questions. Surely the problem is with me, but a clarification never hurts. 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.
I once again got a bit confused with the distinction between a multiple choice question and many consecutive questions. Surely the problem is with me, but a clarification never hurts. Thanks.
yes that's confusing, I should come up with a better name for them, because this api intended to provide multiple consecutive questions with multiple choices, it's a bit of confusing.
related
#19454
overview
Added a API for asking user multiple questions and get answers, useful for quick fix that need to ask multiple question and get user choice(i.e. import all missing item, choose multiple import crates etc.)
details
Use ShowMessageRequest to send message to user, and get
MessageAction
in return.The major impl is in
ask_for_choice
function and is somewhere twisted as writing async code using callback is certainly very uncomfortable.ask_for_choice
send with a empty request id as can't determine what request id it should belong to.On the
Assists
side, developer basically provide a callback with signature ofdyn FnOnce(&mut SourceChangeBuilder, &[usize]) + Send + 'static
to handle what to do after get user choices results, so it's similar toadd_group
methodtodo
test this with a integration test