lsp: Serialize LSP notifications on background threads (#39403)
This should reduce hiccups when opening large files. Release Notes: - N/A
This commit is contained in:
@@ -42,7 +42,7 @@ impl lsp::notification::Notification for SchemaContentsChanged {
|
||||
type Params = String;
|
||||
}
|
||||
|
||||
pub fn notify_schema_changed(lsp_store: Entity<LspStore>, uri: &String, cx: &App) {
|
||||
pub fn notify_schema_changed(lsp_store: Entity<LspStore>, uri: String, cx: &App) {
|
||||
zlog::trace!(LOGGER => "Notifying schema changed for URI: {:?}", uri);
|
||||
let servers = lsp_store.read_with(cx, |lsp_store, _| {
|
||||
let mut servers = Vec::new();
|
||||
@@ -65,7 +65,7 @@ pub fn notify_schema_changed(lsp_store: Entity<LspStore>, uri: &String, cx: &App
|
||||
for server in servers {
|
||||
zlog::trace!(LOGGER => "Notifying server {:?} of schema change for URI: {:?}", server.server_id(), &uri);
|
||||
// TODO: handle errors
|
||||
server.notify::<SchemaContentsChanged>(uri).ok();
|
||||
server.notify::<SchemaContentsChanged>(uri.clone()).ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,11 +119,12 @@ pub fn cancel_flycheck(
|
||||
lsp_store
|
||||
.read_with(cx, |lsp_store, _| {
|
||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||
server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())?;
|
||||
server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})?
|
||||
.context("lsp ext cancel flycheck")?;
|
||||
})
|
||||
.context("lsp ext cancel flycheck")??;
|
||||
};
|
||||
anyhow::Ok(())
|
||||
})
|
||||
@@ -173,14 +174,15 @@ pub fn run_flycheck(
|
||||
.read_with(cx, |lsp_store, _| {
|
||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||
server.notify::<lsp_store::lsp_ext_command::LspExtRunFlycheck>(
|
||||
&lsp_store::lsp_ext_command::RunFlycheckParams {
|
||||
lsp_store::lsp_ext_command::RunFlycheckParams {
|
||||
text_document: None,
|
||||
},
|
||||
)?;
|
||||
)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})?
|
||||
.context("lsp ext run flycheck")?;
|
||||
})
|
||||
.context("lsp ext run flycheck")??;
|
||||
};
|
||||
anyhow::Ok(())
|
||||
})
|
||||
@@ -224,11 +226,12 @@ pub fn clear_flycheck(
|
||||
lsp_store
|
||||
.read_with(cx, |lsp_store, _| {
|
||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||
server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())?;
|
||||
server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})?
|
||||
.context("lsp ext clear flycheck")?;
|
||||
})
|
||||
.context("lsp ext clear flycheck")??;
|
||||
};
|
||||
anyhow::Ok(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user