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/api | |
| parent | 0fec1199671becba511e03d98a4921e375a46fe3 (diff) | |
feat: configure new terminal cwd
Diffstat (limited to 'src/app/api')
| -rw-r--r-- | src/app/api/panes.rs | 5 | ||||
| -rw-r--r-- | src/app/api/tabs.rs | 16 | ||||
| -rw-r--r-- | src/app/api/workspaces.rs | 11 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/app/api/panes.rs b/src/app/api/panes.rs index 2b1741d9..e0df6845 100644 --- a/src/app/api/panes.rs +++ b/src/app/api/panes.rs @@ -21,14 +21,15 @@ impl App { }; let (rows, cols) = self.state.estimate_pane_size(); let split_cwd = params.cwd.map(std::path::PathBuf::from).or_else(|| { - self.state.workspaces.get(ws_idx).and_then(|ws| { + let follow_cwd = self.state.workspaces.get(ws_idx).and_then(|ws| { let tab_idx = ws.find_tab_index_for_pane(target_pane_id)?; ws.tabs.get(tab_idx)?.cwd_for_pane( target_pane_id, &self.state.terminals, &self.terminal_runtimes, ) - }) + }); + Some(self.resolve_new_terminal_cwd(follow_cwd)) }); let default_shell = self.state.default_shell.clone(); let scrollback_limit_bytes = self.state.pane_scrollback_limit_bytes; diff --git a/src/app/api/tabs.rs b/src/app/api/tabs.rs index 7978a17f..06d59fe3 100644 --- a/src/app/api/tabs.rs +++ b/src/app/api/tabs.rs @@ -63,15 +63,13 @@ impl App { } else { return encode_error(id, "workspace_not_found", "no active workspace"); }; - let cwd = cwd - .map(PathBuf::from) - .or_else(|| { - self.state - .focused_runtime_in_workspace(&self.terminal_runtimes, ws_idx) - .and_then(|rt| rt.cwd()) - }) - .or_else(|| std::env::current_dir().ok()) - .unwrap_or_else(|| PathBuf::from("/")); + let cwd = cwd.map(PathBuf::from).unwrap_or_else(|| { + let follow_cwd = self + .state + .focused_runtime_in_workspace(&self.terminal_runtimes, ws_idx) + .and_then(|rt| rt.cwd()); + self.resolve_new_terminal_cwd(follow_cwd) + }); let (rows, cols) = self.state.estimate_pane_size(); let default_shell = self.state.default_shell.clone(); let scrollback_limit_bytes = self.state.pane_scrollback_limit_bytes; diff --git a/src/app/api/workspaces.rs b/src/app/api/workspaces.rs index f5e9a563..92b41486 100644 --- a/src/app/api/workspaces.rs +++ b/src/app/api/workspaces.rs @@ -45,11 +45,12 @@ impl App { id: String, params: WorkspaceCreateParams, ) -> String { - let cwd = params - .cwd - .map(PathBuf::from) - .or_else(|| std::env::current_dir().ok()) - .unwrap_or_else(|| PathBuf::from("/")); + let cwd = params.cwd.map(PathBuf::from).unwrap_or_else(|| { + let follow_cwd = self + .workspace_creation_source() + .and_then(|ws_idx| self.seed_cwd_from_workspace(ws_idx)); + self.resolve_new_terminal_cwd(follow_cwd) + }); match self.create_workspace_with_options(cwd, params.focus) { Ok(index) => { if let Some(label) = params.label { |
