1+ use std:: future:: Future ;
12use std:: sync:: Arc ;
23
34use anyhow:: { Context as _, Result } ;
@@ -10,7 +11,8 @@ use project::{Fs, Project, WorktreeId};
1011use settings:: { Settings , SettingsStore } ;
1112
1213use crate :: kernels:: {
13- list_remote_kernelspecs, local_kernel_specifications, python_env_kernel_specifications,
14+ Kernel , list_remote_kernelspecs, local_kernel_specifications,
15+ python_env_kernel_specifications,
1416} ;
1517use crate :: { JupyterSettings , KernelSpecification , Session } ;
1618
@@ -47,9 +49,12 @@ impl ReplStore {
4749 }
4850
4951 pub fn new ( fs : Arc < dyn Fs > , cx : & mut Context < Self > ) -> Self {
50- let subscriptions = vec ! [ cx. observe_global:: <SettingsStore >( move |this, cx| {
51- this. set_enabled( JupyterSettings :: enabled( cx) , cx) ;
52- } ) ] ;
52+ let subscriptions = vec ! [
53+ cx. observe_global:: <SettingsStore >( move |this, cx| {
54+ this. set_enabled( JupyterSettings :: enabled( cx) , cx) ;
55+ } ) ,
56+ cx. on_app_quit( Self :: shutdown_all_sessions) ,
57+ ] ;
5358
5459 let this = Self {
5560 fs,
@@ -281,6 +286,16 @@ impl ReplStore {
281286 self . sessions . remove ( & entity_id) ;
282287 }
283288
289+ fn shutdown_all_sessions ( & mut self , cx : & mut Context < Self > ) -> impl Future < Output = ( ) > + use < > {
290+ for session in self . sessions . values ( ) {
291+ session. update ( cx, |session, _cx| {
292+ session. kernel = Kernel :: Shutdown ;
293+ } ) ;
294+ }
295+ self . sessions . clear ( ) ;
296+ futures:: future:: ready ( ( ) )
297+ }
298+
284299 #[ cfg( test) ]
285300 pub fn set_kernel_specs_for_testing (
286301 & mut self ,
0 commit comments