@@ -378,12 +378,12 @@ pub enum Message {
378378 ProfileName ( ProfileId , String ) ,
379379 ProfileNew ,
380380 ProfileOpen ( ProfileId ) ,
381+ ProfileOpenInCWD ( ProfileId , bool ) ,
381382 ProfileRemove ( ProfileId ) ,
382383 ProfileSyntaxTheme ( ProfileId , ColorSchemeKind , usize ) ,
383384 ProfileTabTitle ( ProfileId , String ) ,
384385 Surface ( surface:: Action ) ,
385386 SelectAll ( Option < segmented_button:: Entity > ) ,
386- SetOpenInCWD ( bool ) ,
387387 ShowAdvancedFontSettings ( bool ) ,
388388 ShowHeaderBar ( bool ) ,
389389 SyntaxTheme ( ColorSchemeKind , usize ) ,
@@ -1042,6 +1042,13 @@ impl App {
10421042 ] )
10431043 . align_y ( Alignment :: Center )
10441044 . padding ( [ 0 , space_s] ) ,
1045+ )
1046+ . add (
1047+ widget:: settings:: item:: builder ( fl ! ( "open-in-cwd" ) )
1048+ . description ( fl ! ( "open-in-cwd-description" ) )
1049+ . toggler ( profile. open_in_cwd , move |open_in_cwd| {
1050+ Message :: ProfileOpenInCWD ( profile_id, open_in_cwd)
1051+ } ) ,
10451052 ) ;
10461053
10471054 let padding = Padding {
@@ -1249,18 +1256,11 @@ impl App {
12491256 . toggler ( self . config . focus_follow_mouse , Message :: FocusFollowMouse ) ,
12501257 ) ;
12511258
1252- let advanced_section = widget:: settings:: section ( )
1253- . title ( fl ! ( "advanced" ) )
1254- . add (
1255- widget:: settings:: item:: builder ( fl ! ( "show-headerbar" ) )
1256- . description ( fl ! ( "show-header-description" ) )
1257- . toggler ( self . config . show_headerbar , Message :: ShowHeaderBar ) ,
1258- )
1259- . add (
1260- widget:: settings:: item:: builder ( fl ! ( "open-in-cwd" ) )
1261- . description ( fl ! ( "open-in-cwd-description" ) )
1262- . toggler ( self . config . open_in_cwd , Message :: SetOpenInCWD ) ,
1263- ) ;
1259+ let advanced_section = widget:: settings:: section ( ) . title ( fl ! ( "advanced" ) ) . add (
1260+ widget:: settings:: item:: builder ( fl ! ( "show-headerbar" ) )
1261+ . description ( fl ! ( "show-header-description" ) )
1262+ . toggler ( self . config . show_headerbar , Message :: ShowHeaderBar ) ,
1263+ ) ;
12641264
12651265 widget:: settings:: view_column ( vec ! [
12661266 appearance_section. into( ) ,
@@ -1302,28 +1302,6 @@ impl App {
13021302 let ( options, tab_title_override) = match self . startup_options . take ( ) {
13031303 Some ( options) => ( options, None ) ,
13041304 None => {
1305- // Current working directory of the selected tab/terminal
1306- #[ cfg( not( windows) ) ]
1307- let cwd = self
1308- . config
1309- . open_in_cwd
1310- . then ( || {
1311- tab_model. active_data :: < Mutex < Terminal > > ( ) . and_then (
1312- |terminal| {
1313- terminal
1314- . lock ( )
1315- . unwrap ( )
1316- . current_working_directory ( )
1317- } ,
1318- )
1319- } )
1320- . flatten ( ) ;
1321- // Or default to the profile working directory
1322- #[ cfg( windows) ]
1323- let cwd: Option <
1324- std:: path:: PathBuf ,
1325- > = None ;
1326-
13271305 match profile_id_opt. and_then ( |profile_id| {
13281306 self . config . profiles . get ( & profile_id)
13291307 } ) {
@@ -1335,6 +1313,25 @@ impl App {
13351313 shell = Some ( tty:: Shell :: new ( command, args) ) ;
13361314 }
13371315 }
1316+ // Current working directory of the selected tab/terminal
1317+ #[ cfg( not( windows) ) ]
1318+ let cwd = profile
1319+ . open_in_cwd
1320+ . then ( || {
1321+ tab_model
1322+ . active_data :: < Mutex < Terminal > > ( )
1323+ . and_then ( |terminal| {
1324+ terminal
1325+ . lock ( )
1326+ . unwrap ( )
1327+ . current_working_directory ( )
1328+ } )
1329+ } )
1330+ . flatten ( ) ;
1331+ // Or default to the profile working directory
1332+ #[ cfg( windows) ]
1333+ let cwd: Option < std:: path:: PathBuf > = None ;
1334+
13381335 let working_directory = cwd. or_else ( || {
13391336 Some ( profile. working_directory . clone ( ) . into ( ) )
13401337 } ) ;
@@ -1355,7 +1352,17 @@ impl App {
13551352 None => {
13561353 let mut options =
13571354 self . startup_options . take ( ) . unwrap_or_default ( ) ;
1358- options. working_directory = cwd;
1355+ #[ cfg( not( windows) ) ]
1356+ {
1357+ options. working_directory = tab_model
1358+ . active_data :: < Mutex < Terminal > > ( )
1359+ . and_then ( |terminal| {
1360+ terminal
1361+ . lock ( )
1362+ . unwrap ( )
1363+ . current_working_directory ( )
1364+ } ) ;
1365+ }
13591366 ( options, None )
13601367 }
13611368 }
@@ -2253,6 +2260,13 @@ impl Application for App {
22532260 return self
22542261 . create_and_focus_new_terminal ( self . pane_model . focused ( ) , Some ( profile_id) ) ;
22552262 }
2263+ Message :: ProfileOpenInCWD ( profile_id, open_in_cwd) => {
2264+ #[ cfg( not( windows) ) ]
2265+ if let Some ( profile) = self . config . profiles . get_mut ( & profile_id) {
2266+ profile. open_in_cwd = open_in_cwd;
2267+ return self . save_profiles ( ) ;
2268+ }
2269+ }
22562270 Message :: ProfileRemove ( profile_id) => {
22572271 // Reset matching terminals to default profile
22582272 for ( _pane, tab_model) in self . pane_model . panes . iter ( ) {
@@ -2311,12 +2325,6 @@ impl Application for App {
23112325 }
23122326 return self . update_focus ( ) ;
23132327 }
2314- Message :: SetOpenInCWD ( open_in_cwd) => {
2315- if open_in_cwd != self . config . open_in_cwd {
2316- self . config . open_in_cwd = open_in_cwd;
2317- return self . update_config ( ) ;
2318- }
2319- }
23202328 Message :: ShowHeaderBar ( show_headerbar) => {
23212329 if show_headerbar != self . config . show_headerbar {
23222330 config_set ! ( show_headerbar, show_headerbar) ;
0 commit comments