diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-23 00:32:46 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-23 00:32:46 +0300 |
| commit | 3de6ea799965a7d2aad0f7db2f23f54cd24cb039 (patch) | |
| tree | c9233a7f3d432aed7761c9db9c0072fee4ff5de2 /src/app/mod.rs | |
| parent | 0fec1199671becba511e03d98a4921e375a46fe3 (diff) | |
feat: configure new terminal cwd
Diffstat (limited to 'src/app/mod.rs')
| -rw-r--r-- | src/app/mod.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs index 1eeba25b..4bcbada7 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -454,6 +454,7 @@ impl App { cjk_ime_cursor_shape: config.experimental.cjk_ime_cursor_shape.to_decscusr(), kitty_graphics_enabled: config.experimental.kitty_graphics, default_shell: config.terminal.default_shell.clone(), + new_terminal_cwd: config.terminal.new_cwd.clone(), pane_scrollback_limit_bytes: config.advanced.scrollback_limit_bytes, accent: crate::config::parse_color(&config.ui.accent), sound: config.ui.sound.clone(), @@ -1004,6 +1005,7 @@ impl App { if !invalid_section("terminal") { self.state.default_shell = config.terminal.default_shell.clone(); + self.state.new_terminal_cwd = config.terminal.new_cwd.clone(); } if !invalid_section("worktrees") { @@ -1461,7 +1463,7 @@ mod tests { std::fs::create_dir_all(path.parent().unwrap()).unwrap(); std::fs::write( &path, - "[terminal]\ndefault_shell = \"nu\"\n[keys]\nnew_workspace = \"prefix+g\"\nprefix = \"ctrl+a\"\n[ui]\nagent_panel_scope = \"current\"\n[ui.toast]\ndelivery = \"herdr\"\n", + "[terminal]\ndefault_shell = \"nu\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+g\"\nprefix = \"ctrl+a\"\n[ui]\nagent_panel_scope = \"current\"\n[ui.toast]\ndelivery = \"herdr\"\n", ) .unwrap(); std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path); @@ -1486,6 +1488,10 @@ mod tests { state::AgentPanelScope::CurrentWorkspace ); assert_eq!(app.state.default_shell, "nu"); + assert_eq!( + app.state.new_terminal_cwd, + crate::config::NewTerminalCwdConfig::Home + ); assert!(app.state.config_diagnostic.is_none()); let toast = app.state.toast.as_ref().unwrap(); assert_eq!(toast.kind, crate::app::state::ToastKind::UpdateInstalled); @@ -2055,6 +2061,26 @@ mod tests { } #[test] + fn new_terminal_cwd_follow_uses_source_cwd() { + let cwd = creation::resolve_new_terminal_cwd( + &crate::config::NewTerminalCwdConfig::Follow, + Some(std::path::PathBuf::from("/tmp/herdr-source")), + ); + + assert_eq!(cwd, std::path::PathBuf::from("/tmp/herdr-source")); + } + + #[test] + fn new_terminal_cwd_path_uses_configured_path() { + let cwd = creation::resolve_new_terminal_cwd( + &crate::config::NewTerminalCwdConfig::Path("/tmp/herdr-fixed".into()), + Some(std::path::PathBuf::from("/tmp/herdr-source")), + ); + + assert_eq!(cwd, std::path::PathBuf::from("/tmp/herdr-fixed")); + } + + #[test] fn server_stop_request_sets_should_quit_flag() { let mut app = test_app(); |
