From 1533c17cd772f89487cf2502827780d4fad611b6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 27 Apr 2023 14:39:00 -0700 Subject: [PATCH] Shutdown copilot server when quitting zed --- crates/copilot/src/copilot.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 13aa904b5c..a5d26f8254 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>>> { + 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 {