diff options
Diffstat (limited to 'src/app/creation.rs')
| -rw-r--r-- | src/app/creation.rs | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/app/creation.rs b/src/app/creation.rs index 2e978ee9..fc01710e 100644 --- a/src/app/creation.rs +++ b/src/app/creation.rs @@ -30,6 +30,24 @@ pub(crate) fn resolve_new_terminal_cwd( } } +pub(super) fn launch_cwd_for_terminal( + terminal_id: &crate::terminal::TerminalId, + terminals: &std::collections::HashMap< + crate::terminal::TerminalId, + crate::terminal::TerminalState, + >, + terminal_runtimes: &crate::terminal::TerminalRuntimeRegistry, +) -> Option<PathBuf> { + terminal_runtimes + .get(terminal_id) + .and_then(|runtime| runtime.follow_cwd()) + .or_else(|| { + terminals + .get(terminal_id) + .map(|terminal| terminal.cwd.clone()) + }) +} + impl App { pub(super) fn seed_cwd_from_workspace(&self, ws_idx: usize) -> Option<PathBuf> { self.state @@ -38,15 +56,17 @@ impl App { .resolved_identity_cwd_from(&self.state.terminals, &self.terminal_runtimes) } - pub(super) fn follow_cwd_for_pane_in_workspace( + pub(super) fn launch_cwd_for_pane_in_workspace( &self, ws_idx: usize, pane_id: crate::layout::PaneId, ) -> Option<PathBuf> { - let ws = self.state.workspaces.get(ws_idx)?; - let tab_idx = ws.find_tab_index_for_pane(pane_id)?; - ws.tabs.get(tab_idx)?.follow_cwd_for_pane( - pane_id, + let workspace = self.state.workspaces.get(ws_idx)?; + let tab = workspace + .tabs + .get(workspace.find_tab_index_for_pane(pane_id)?)?; + launch_cwd_for_terminal( + tab.terminal_id(pane_id)?, &self.state.terminals, &self.terminal_runtimes, ) @@ -54,7 +74,7 @@ impl App { pub(super) fn focused_pane_cwd_in_workspace(&self, ws_idx: usize) -> Option<PathBuf> { let pane_id = self.state.workspaces.get(ws_idx)?.focused_pane_id()?; - self.follow_cwd_for_pane_in_workspace(ws_idx, pane_id) + self.launch_cwd_for_pane_in_workspace(ws_idx, pane_id) } pub(super) fn resolve_new_terminal_cwd(&self, follow_cwd: Option<PathBuf>) -> PathBuf { |
