@@ -331,11 +331,11 @@ pub enum Message {
331331 ProfileName ( ProfileId , String ) ,
332332 ProfileNew ,
333333 ProfileOpen ( ProfileId ) ,
334+ ProfileOpenInCWD ( ProfileId , bool ) ,
334335 ProfileRemove ( ProfileId ) ,
335336 ProfileSyntaxTheme ( ProfileId , ColorSchemeKind , usize ) ,
336337 ProfileTabTitle ( ProfileId , String ) ,
337338 SelectAll ( Option < segmented_button:: Entity > ) ,
338- SetOpenInCWD ( bool ) ,
339339 ShowAdvancedFontSettings ( bool ) ,
340340 ShowHeaderBar ( bool ) ,
341341 SyntaxTheme ( ColorSchemeKind , usize ) ,
@@ -477,7 +477,6 @@ impl App {
477477 . sort_by ( |a, b| LANGUAGE_SORTER . compare ( a, b) ) ;
478478 }
479479
480-
481480 fn reset_terminal_panes_zoom ( & mut self ) {
482481 for ( _pane, tab_model) in self . pane_model . panes . iter ( ) {
483482 for entity in tab_model. iter ( ) {
@@ -534,8 +533,12 @@ impl App {
534533 let mut terminal = terminal. lock ( ) . unwrap ( ) ;
535534 let current_zoom_adj = terminal. zoom_adj ( ) ;
536535 match zoom_message {
537- Message :: ZoomIn => terminal. set_zoom_adj ( current_zoom_adj. saturating_add ( 1 ) ) ,
538- Message :: ZoomOut => terminal. set_zoom_adj ( current_zoom_adj. saturating_sub ( 1 ) ) ,
536+ Message :: ZoomIn => {
537+ terminal. set_zoom_adj ( current_zoom_adj. saturating_add ( 1 ) )
538+ }
539+ Message :: ZoomOut => {
540+ terminal. set_zoom_adj ( current_zoom_adj. saturating_sub ( 1 ) )
541+ }
539542 _ => { }
540543 }
541544 terminal. set_config ( & self . config , & self . themes ) ;
@@ -989,6 +992,13 @@ impl App {
989992 ] )
990993 . align_items ( Alignment :: Center )
991994 . padding ( [ 0 , space_s] ) ,
995+ )
996+ . add (
997+ widget:: settings:: item:: builder ( fl ! ( "open-in-cwd" ) )
998+ . description ( fl ! ( "open-in-cwd-description" ) )
999+ . toggler ( profile. open_in_cwd , move |open_in_cwd| {
1000+ Message :: ProfileOpenInCWD ( profile_id, open_in_cwd)
1001+ } ) ,
9921002 ) ;
9931003
9941004 let padding = Padding {
@@ -1194,17 +1204,11 @@ impl App {
11941204 . toggler ( self . config . focus_follow_mouse , Message :: FocusFollowMouse ) ,
11951205 ) ;
11961206
1197- let advanced_section = widget:: settings:: view_section ( fl ! ( "advanced" ) )
1198- . add (
1199- widget:: settings:: item:: builder ( fl ! ( "show-headerbar" ) )
1200- . description ( fl ! ( "show-header-description" ) )
1201- . toggler ( self . config . show_headerbar , Message :: ShowHeaderBar ) ,
1202- )
1203- . add (
1204- widget:: settings:: item:: builder ( fl ! ( "open-in-cwd" ) )
1205- . description ( fl ! ( "open-in-cwd-description" ) )
1206- . toggler ( self . config . open_in_cwd , Message :: SetOpenInCWD ) ,
1207- ) ;
1207+ let advanced_section = widget:: settings:: view_section ( fl ! ( "advanced" ) ) . add (
1208+ widget:: settings:: item:: builder ( fl ! ( "show-headerbar" ) )
1209+ . description ( fl ! ( "show-header-description" ) )
1210+ . toggler ( self . config . show_headerbar , Message :: ShowHeaderBar ) ,
1211+ ) ;
12081212
12091213 widget:: settings:: view_column ( vec ! [
12101214 appearance_section. into( ) ,
@@ -1242,22 +1246,6 @@ impl App {
12421246 Some ( colors) => {
12431247 let current_pane = self . pane_model . focus ;
12441248 if let Some ( tab_model) = self . pane_model . active_mut ( ) {
1245- // Current working directory of the selected tab/terminal
1246- #[ cfg( not( windows) ) ]
1247- let cwd = self
1248- . config
1249- . open_in_cwd
1250- . then ( || {
1251- tab_model. active_data :: < Mutex < Terminal > > ( ) . and_then (
1252- |terminal| {
1253- terminal. lock ( ) . unwrap ( ) . current_working_directory ( )
1254- } ,
1255- )
1256- } )
1257- . flatten ( ) ;
1258- #[ cfg( windows) ]
1259- let cwd: Option < std:: path:: PathBuf > = None ;
1260-
12611249 // Use the profile options, startup options, or defaults
12621250 let ( options, tab_title_override) = match profile_id_opt
12631251 . and_then ( |profile_id| self . config . profiles . get ( & profile_id) )
@@ -1270,8 +1258,27 @@ impl App {
12701258 shell = Some ( tty:: Shell :: new ( command, args) ) ;
12711259 }
12721260 }
1273- let working_directory = cwd
1261+
1262+ #[ cfg( not( windows) ) ]
1263+ let working_directory = profile
1264+ . open_in_cwd
1265+ // Evaluate current working working directory based on
1266+ // selected tab/terminal
1267+ . then ( || {
1268+ tab_model. active_data :: < Mutex < Terminal > > ( ) . and_then (
1269+ |terminal| {
1270+ terminal
1271+ . lock ( )
1272+ . unwrap ( )
1273+ . current_working_directory ( )
1274+ } ,
1275+ )
1276+ } )
1277+ . flatten ( )
12741278 . or_else ( || Some ( profile. working_directory . clone ( ) . into ( ) ) ) ;
1279+ #[ cfg( windows) ]
1280+ let working_directory = ( !profile. working_directory . is_empty ( ) )
1281+ . then ( || profile. working_directory . clone ( ) . into ( ) ) ;
12751282
12761283 let options = tty:: Options {
12771284 shell,
@@ -1289,7 +1296,15 @@ impl App {
12891296 None => {
12901297 let mut options =
12911298 self . startup_options . take ( ) . unwrap_or_default ( ) ;
1292- options. working_directory = cwd;
1299+ #[ cfg( not( windows) ) ]
1300+ {
1301+ // Eval CWD since it's the default option
1302+ options. working_directory = tab_model
1303+ . active_data :: < Mutex < Terminal > > ( )
1304+ . and_then ( |terminal| {
1305+ terminal. lock ( ) . unwrap ( ) . current_working_directory ( )
1306+ } ) ;
1307+ }
12931308 ( options, None )
12941309 }
12951310 } ;
@@ -2158,6 +2173,13 @@ impl Application for App {
21582173 Message :: ProfileOpen ( profile_id) => {
21592174 return self . create_and_focus_new_terminal ( self . pane_model . focus , Some ( profile_id) ) ;
21602175 }
2176+ Message :: ProfileOpenInCWD ( profile_id, open_in_cwd) => {
2177+ #[ cfg( not( windows) ) ]
2178+ if let Some ( profile) = self . config . profiles . get_mut ( & profile_id) {
2179+ profile. open_in_cwd = open_in_cwd;
2180+ return self . save_profiles ( ) ;
2181+ }
2182+ }
21612183 Message :: ProfileRemove ( profile_id) => {
21622184 // Reset matching terminals to default profile
21632185 for ( _pane, tab_model) in self . pane_model . panes . iter ( ) {
@@ -2216,12 +2238,6 @@ impl Application for App {
22162238 }
22172239 return self . update_focus ( ) ;
22182240 }
2219- Message :: SetOpenInCWD ( open_in_cwd) => {
2220- if open_in_cwd != self . config . open_in_cwd {
2221- self . config . open_in_cwd = open_in_cwd;
2222- return self . save_config ( ) ;
2223- }
2224- }
22252241 Message :: ShowHeaderBar ( show_headerbar) => {
22262242 if show_headerbar != self . config . show_headerbar {
22272243 config_set ! ( show_headerbar, show_headerbar) ;
0 commit comments