@ -43,6 +43,8 @@ pub struct EditorView {
pub ( crate ) last_insert : ( commands ::MappableCommand , Vec < InsertEvent > ) ,
pub ( crate ) last_insert : ( commands ::MappableCommand , Vec < InsertEvent > ) ,
pub ( crate ) completion : Option < Completion > ,
pub ( crate ) completion : Option < Completion > ,
spinners : ProgressSpinners ,
spinners : ProgressSpinners ,
/// Tracks if the terminal window is focused by reaction to terminal focus events
terminal_focused : bool ,
}
}
#[ derive(Debug, Clone) ]
#[ derive(Debug, Clone) ]
@ -71,6 +73,7 @@ impl EditorView {
last_insert : ( commands ::MappableCommand ::normal_mode , Vec ::new ( ) ) ,
last_insert : ( commands ::MappableCommand ::normal_mode , Vec ::new ( ) ) ,
completion : None ,
completion : None ,
spinners : ProgressSpinners ::default ( ) ,
spinners : ProgressSpinners ::default ( ) ,
terminal_focused : true ,
}
}
}
}
@ -171,7 +174,7 @@ impl EditorView {
view ,
view ,
view . area ,
view . area ,
theme ,
theme ,
is_focused ,
is_focused & self . terminal_focused ,
& mut line_decorations ,
& mut line_decorations ,
) ;
) ;
}
}
@ -1372,13 +1375,17 @@ impl Component for EditorView {
Event ::Mouse ( event ) = > self . handle_mouse_event ( event , & mut cx ) ,
Event ::Mouse ( event ) = > self . handle_mouse_event ( event , & mut cx ) ,
Event ::IdleTimeout = > self . handle_idle_timeout ( & mut cx ) ,
Event ::IdleTimeout = > self . handle_idle_timeout ( & mut cx ) ,
Event ::FocusGained = > EventResult ::Ignored ( None ) ,
Event ::FocusGained = > {
self . terminal_focused = true ;
EventResult ::Consumed ( None )
}
Event ::FocusLost = > {
Event ::FocusLost = > {
if context . editor . config ( ) . auto_save {
if context . editor . config ( ) . auto_save {
if let Err ( e ) = commands ::typed ::write_all_impl ( context , false , false ) {
if let Err ( e ) = commands ::typed ::write_all_impl ( context , false , false ) {
context . editor . set_error ( format! ( "{}" , e ) ) ;
context . editor . set_error ( format! ( "{}" , e ) ) ;
}
}
}
}
self . terminal_focused = false ;
EventResult ::Consumed ( None )
EventResult ::Consumed ( None )
}
}
}
}