-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: auto import all missing items #19454
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?
Conversation
88f0ee9
to
982953a
Compare
Rust-analyzer can potentially ask the user by sending a ShowMessage Request. (It seems the current code does not contain an example for this) |
is adding this two methods to /// For scenarios where the user needs to select one or more options from a predefined list
pub(crate) fn add_multi_select_choice(
&mut self,
group: &GroupLabel,
id: AssistId,
label: impl Into<String>,
target: TextRange,
choices: Vec<Vec<String>>,
f: impl FnOnce(&mut SourceChangeBuilder, &[String]),
) -> Option<()> {
todo!()
}
/// For scenarios requiring sequential, stateful interactions where choices influence subsequent steps.
pub(crate) fn add_multi_step_choice(
&mut self,
group: &GroupLabel,
id: AssistId,
label: impl Into<String>,
target: TextRange,
first_choice: Vec<String>,
f: Vec<Box<dyn FnOnce(&mut SourceChangeBuilder, &str)->Vec<String>>>,
) -> Option<()> {
todo!()
} |
I'm not qualified to determine that, but ...
... a single ShowMessage request cannot be used to select more than one options. However, multiple requests can achieve this. For example, if there are three options: A, B, C, then the user can select A and B with the following exchange: sequenceDiagram
RA ->> LSP Client: ShowMessageRequest(["[ ] Option A", "[ ] Option B", "[ ] Option C", "Proceed")
LSP Client ->> RA: ActionItem("[ ] Option B")
RA ->> LSP Client: ShowMessageRequest(["[ ] Option A", "[X] Option B", "[ ] Option C", "Proceed")
LSP Client ->> RA: ActionItem("[ ] Option A")
RA ->> LSP Client: ShowMessageRequest(["[X] Option A", "[X] Option B", "[ ] Option C", "Proceed")
LSP Client ->> RA: ActionItem("Proceed")
|
Yes, I don't mean mutli-select, but providing multiple question each with choices(and user choose one from each), I think that's likely the suitable way(a good enough api on the |
Related Issue
#12761
Import all missing items
add a new assist to automatically import all missing items in scope.
For now it will only pick the most likely import when multiple import choices is found, this might could be improved by asking user which one do they want, but I can't figure out how to do that now