Explicitly shut down language servers when quitting the app

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2021-11-02 13:16:25 -06:00
parent 882c8ce696
commit 2c57703ad6
5 changed files with 161 additions and 102 deletions

View file

@ -20,6 +20,7 @@ use postage::{
prelude::{Sink as _, Stream as _},
watch,
};
use serde::Deserialize;
use smol::channel::{self, Sender};
use std::{
@ -90,6 +91,25 @@ impl Entity for Worktree {
}
}
}
fn app_will_quit(
&mut self,
_: &mut MutableAppContext,
) -> Option<std::pin::Pin<Box<dyn 'static + Future<Output = ()>>>> {
use futures::FutureExt;
if let Some(server) = self.language_server() {
if let Some(shutdown) = server.shutdown() {
return Some(
async move {
shutdown.await.log_err();
}
.boxed(),
);
}
}
None
}
}
impl Worktree {