aboutsummaryrefslogtreecommitdiff
path: root/src/app/creation.rs
diff options
context:
space:
mode:
authorPitchfork-and-Torch <Pitchfork-and-Torch@users.noreply.github.com>2026-07-09 21:11:52 -0400
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-10 15:06:54 +0300
commit4f7fcc48d1f760ab6057d0964f009c05b753456a (patch)
treeee617c2d12d4c33c2c63a6a8048ab9e80a11d225 /src/app/creation.rs
parentc8850a2e3e284033142db0f8117fa5998c68bd59 (diff)
fix: follow foreground cwd for new terminals
refs #1245
Diffstat (limited to 'src/app/creation.rs')
-rw-r--r--src/app/creation.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/app/creation.rs b/src/app/creation.rs
index 13fc0a8e..734c57aa 100644
--- a/src/app/creation.rs
+++ b/src/app/creation.rs
@@ -38,21 +38,23 @@ impl App {
.resolved_identity_cwd_from(&self.state.terminals, &self.terminal_runtimes)
}
- pub(super) fn cwd_for_pane_in_workspace(
+ pub(super) fn follow_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)?
- .cwd_for_pane(pane_id, &self.state.terminals, &self.terminal_runtimes)
+ ws.tabs.get(tab_idx)?.follow_cwd_for_pane(
+ pane_id,
+ &self.state.terminals,
+ &self.terminal_runtimes,
+ )
}
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.cwd_for_pane_in_workspace(ws_idx, pane_id)
+ self.follow_cwd_for_pane_in_workspace(ws_idx, pane_id)
}
pub(super) fn resolve_new_terminal_cwd(&self, follow_cwd: Option<PathBuf>) -> PathBuf {
@@ -77,9 +79,10 @@ impl App {
/// Create a workspace with a real PTY (needs event_tx).
#[cfg(test)]
pub(crate) fn create_workspace(&mut self) {
- let follow_cwd = self
- .workspace_creation_source()
- .and_then(|ws_idx| self.seed_cwd_from_workspace(ws_idx));
+ let follow_cwd = self.workspace_creation_source().and_then(|ws_idx| {
+ self.focused_pane_cwd_in_workspace(ws_idx)
+ .or_else(|| self.seed_cwd_from_workspace(ws_idx))
+ });
let initial_cwd = self.resolve_new_terminal_cwd(follow_cwd);
if let Err(e) = self.create_workspace_with_events(initial_cwd, true) {
error!(err = %e, "failed to create workspace");
@@ -91,10 +94,10 @@ impl App {
pub(crate) fn create_tab(&mut self) {
let custom_name = self.state.requested_new_tab_name.take();
let active_before = self.state.active;
- let follow_cwd = self
- .state
- .active
- .and_then(|ws_idx| self.seed_cwd_from_workspace(ws_idx));
+ let follow_cwd = self.state.active.and_then(|ws_idx| {
+ self.focused_pane_cwd_in_workspace(ws_idx)
+ .or_else(|| self.seed_cwd_from_workspace(ws_idx))
+ });
let initial_cwd = self.resolve_new_terminal_cwd(follow_cwd);
match self.create_tab_with_options(initial_cwd, true) {
Ok(created_idx) => {