Switch LSP prompts to use a non-blocking toast (#8312)
This fixes a major degradation in usability that some users ran into. Fixes https://github.com/zed-industries/zed/issues/8255 Fixes https://github.com/zed-industries/zed/issues/8229 Release Notes: - Switch from using platform prompts to toasts for LSP prompts. ([8255](https://github.com/zed-industries/zed/issues/8255), [8229](https://github.com/zed-industries/zed/issues/8229)) <img width="583" alt="Screenshot 2024-02-23 at 2 40 05 PM" src="https://github.com/zed-industries/zed/assets/2280405/1bfc027b-b7a8-4563-88b6-020e47869668"> Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
d993dd3b2c
commit
cab8b5a9a3
7 changed files with 145 additions and 21 deletions
|
@ -59,7 +59,10 @@ use std::{
|
|||
any::TypeId,
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
cmp, env,
|
||||
cmp,
|
||||
collections::hash_map::DefaultHasher,
|
||||
env,
|
||||
hash::{Hash, Hasher},
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
sync::{atomic::AtomicUsize, Arc, Weak},
|
||||
|
@ -579,24 +582,13 @@ impl Workspace {
|
|||
}),
|
||||
|
||||
project::Event::LanguageServerPrompt(request) => {
|
||||
let request = request.clone();
|
||||
let mut hasher = DefaultHasher::new();
|
||||
request.message.as_str().hash(&mut hasher);
|
||||
let id = hasher.finish();
|
||||
|
||||
cx.spawn(|_, mut cx| async move {
|
||||
let messages = request
|
||||
.actions
|
||||
.iter()
|
||||
.map(|action| action.title.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
let index = cx
|
||||
.update(|cx| {
|
||||
cx.prompt(request.level, "", Some(&request.message), &messages)
|
||||
})?
|
||||
.await?;
|
||||
request.respond(index).await;
|
||||
|
||||
Result::<(), anyhow::Error>::Ok(())
|
||||
})
|
||||
.detach()
|
||||
this.show_notification(id as usize, cx, |cx| {
|
||||
cx.new_view(|_| notifications::LanguageServerPrompt::new(request.clone()))
|
||||
});
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
@ -2766,7 +2758,7 @@ impl Workspace {
|
|||
.z_index(100)
|
||||
.right_3()
|
||||
.bottom_3()
|
||||
.w_96()
|
||||
.w_112()
|
||||
.h_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue