@ -366,30 +366,40 @@ impl Application {
self . editor . refresh_config ( ) ;
self . editor . refresh_config ( ) ;
}
}
fn refresh_config ( & mut self ) {
/// Refresh theme after config change
let config = Config ::load_default ( ) . unwrap_or_else ( | err | {
fn refresh_theme ( & mut self , config : & Config ) {
self . editor . set_error ( err . to_string ( ) ) ;
Config ::default ( )
} ) ;
// Refresh theme
if let Some ( theme ) = config . theme . clone ( ) {
if let Some ( theme ) = config . theme . clone ( ) {
let true_color = self . true_color ( ) ;
let true_color = self . true_color ( ) ;
self . editor . set_theme (
match self . theme_loader . load ( & theme ) {
self . theme_loader
Ok ( theme ) = > {
. load ( & theme )
if true_color | | theme . is_16_color ( ) {
. map_err ( | e | {
self . editor . set_theme ( theme ) ;
log ::warn ! ( "failed to load theme `{}` - {}" , theme , e ) ;
} else {
e
self . editor
} )
. set_error ( "theme requires truecolor support, which is not available" ) ;
. ok ( )
}
. filter ( | theme | ( true_color | | theme . is_16_color ( ) ) )
}
. unwrap_or_else ( | | self . theme_loader . default_theme ( true_color ) ) ,
Err ( err ) = > {
) ;
let err_string = format! ( "failed to load theme `{}` - {}" , theme , err ) ;
self . editor . set_error ( err_string ) ;
}
}
}
}
}
fn refresh_config ( & mut self ) {
match Config ::load_default ( ) {
Ok ( config ) = > {
self . refresh_theme ( & config ) ;
// Store new config
self . config . store ( Arc ::new ( config ) ) ;
self . config . store ( Arc ::new ( config ) ) ;
}
}
Err ( err ) = > {
self . editor . set_error ( err . to_string ( ) ) ;
}
}
}
fn true_color ( & self ) -> bool {
fn true_color ( & self ) -> bool {
self . config . load ( ) . editor . true_color | | crate ::true_color ( )
self . config . load ( ) . editor . true_color | | crate ::true_color ( )