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:
Mikayla Maki 2024-02-23 15:18:32 -08:00 committed by GitHub
parent d993dd3b2c
commit cab8b5a9a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 145 additions and 21 deletions

View file

@ -229,6 +229,7 @@ pub struct LanguageServerPromptRequest {
pub level: PromptLevel,
pub message: String,
pub actions: Vec<MessageActionItem>,
pub lsp_name: String,
response_channel: Sender<MessageActionItem>,
}
@ -3022,6 +3023,7 @@ impl Project {
cx.update(|cx| adapter.workspace_configuration(worktree_path, cx))?;
let language_server = pending_server.task.await?;
let name = language_server.name();
language_server
.on_notification::<lsp::notification::PublishDiagnostics, _>({
let adapter = adapter.clone();
@ -3160,8 +3162,10 @@ impl Project {
language_server
.on_request::<lsp::request::ShowMessageRequest, _, _>({
let this = this.clone();
let name = name.to_string();
move |params, mut cx| {
let this = this.clone();
let name = name.to_string();
async move {
if let Some(actions) = params.actions {
let (tx, mut rx) = smol::channel::bounded(1);
@ -3174,6 +3178,7 @@ impl Project {
message: params.message,
actions,
response_channel: tx,
lsp_name: name.clone(),
};
if let Ok(_) = this.update(&mut cx, |_, cx| {
@ -3211,6 +3216,7 @@ impl Project {
}
})
.detach();
let mut initialization_options = adapter.adapter.initialization_options();
match (&mut initialization_options, override_options) {
(Some(initialization_options), Some(override_options)) => {