Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Shutdown copilot server when quitting zed

Max Brunsfeld1533c17cd772
diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs
index 13aa904b5c8..a5d26f8254f 100644
--- a/crates/copilot/src/copilot.rs
+++ b/crates/copilot/src/copilot.rs
@@ -24,6 +24,7 @@ use std::{
mem,
ops::Range,
path::{Path, PathBuf},
+ pin::Pin,
sync::Arc,
};
use util::{
@@ -271,6 +272,20 @@ pub struct Copilot {
impl Entity for Copilot {
type Event = ();
+
+ fn app_will_quit(
+ &mut self,
+ _: &mut AppContext,
+ ) -> Option<Pin<Box<dyn 'static + Future<Output = ()>>>> {
+ match mem::replace(&mut self.server, CopilotServer::Disabled) {
+ CopilotServer::Running(server) => Some(Box::pin(async move {
+ if let Some(shutdown) = server.lsp.shutdown() {
+ shutdown.await;
+ }
+ })),
+ _ => None,
+ }
+ }
}
impl Copilot {