aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Batista de Moraes <51273772+Rodrigodd@users.noreply.github.com>2026-02-23 12:26:34 -0300
committerGitHub <noreply@github.com>2026-02-23 16:26:34 +0100
commit0cfc70a0c0f60ff20ea60171f510e3ee4db0a6d3 (patch)
tree042d9924a5b4f26536608501285fa7be0233fba5
parent[Windows port PR6] refactor: gate daemonization and shell-related functions f... (diff)
downloadsl0ppij-0cfc70a0c0f60ff20ea60171f510e3ee4db0a6d3.tar.gz
sl0ppij-0cfc70a0c0f60ff20ea60171f510e3ee4db0a6d3.tar.xz
sl0ppij-0cfc70a0c0f60ff20ea60171f510e3ee4db0a6d3.zip
fix: make `TerminalAction::OpenFile` also inherit client/pane cwd (#4593)
If a `TerminalAction` does not currently have a specified working directory, it will be set to the cwd of the client/pane that triggered the action. Previously this was only done for `TerminalAction::RunCommand`, with this change it is now also done for `TerminalAction::OpenFile`. This fix the issue where the "edit scrollback" action would not inherit the working directory from the pane, but from the zellij process.
-rw-r--r--zellij-server/src/pty.rs66
1 files changed, 35 insertions, 31 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index 5b3139df..607638e6 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -945,47 +945,51 @@ impl Pty {
}
}
fn fill_cwd(&self, terminal_action: &mut TerminalAction, client_id: ClientId) {
- if let TerminalAction::RunCommand(run_command) = terminal_action {
- if run_command.cwd.is_none() {
- run_command.cwd = self
- .active_panes
- .get(&client_id)
- .and_then(|pane| match pane {
- PaneId::Plugin(plugin_id) => self.plugin_cwds.get(plugin_id).cloned(),
- PaneId::Terminal(id) => {
- // Try to get CWD from OS, fall back to cached value
- self.id_to_child_pid
- .get(id)
- .and_then(|&pid| {
- self.bus
- .os_input
- .as_ref()
- .and_then(|input| input.get_cwd(pid))
- })
- .or_else(|| self.terminal_cwds.get(id).cloned())
- },
- })
- };
+ let cwd = match terminal_action {
+ TerminalAction::RunCommand(run_command) => &mut run_command.cwd,
+ TerminalAction::OpenFile(payload) => &mut payload.cwd,
};
- }
- fn fill_cwd_from_pane_id(&self, terminal_action: &mut TerminalAction, pane_id: &PaneId) {
- if let TerminalAction::RunCommand(run_command) = terminal_action {
- if run_command.cwd.is_none() {
- run_command.cwd = match pane_id {
- PaneId::Terminal(terminal_pane_id) => {
+ if cwd.is_none() {
+ *cwd = self
+ .active_panes
+ .get(&client_id)
+ .and_then(|pane| match pane {
+ PaneId::Plugin(plugin_id) => self.plugin_cwds.get(plugin_id).cloned(),
+ PaneId::Terminal(id) => {
// Try to get CWD from OS, fall back to cached value
self.id_to_child_pid
- .get(terminal_pane_id)
+ .get(id)
.and_then(|&pid| {
self.bus
.os_input
.as_ref()
.and_then(|input| input.get_cwd(pid))
})
- .or_else(|| self.terminal_cwds.get(terminal_pane_id).cloned())
+ .or_else(|| self.terminal_cwds.get(id).cloned())
},
- PaneId::Plugin(plugin_id) => self.plugin_cwds.get(plugin_id).cloned(),
- };
+ })
+ };
+ }
+ fn fill_cwd_from_pane_id(&self, terminal_action: &mut TerminalAction, pane_id: &PaneId) {
+ let cwd = match terminal_action {
+ TerminalAction::RunCommand(run_command) => &mut run_command.cwd,
+ TerminalAction::OpenFile(payload) => &mut payload.cwd,
+ };
+ if cwd.is_none() {
+ *cwd = match pane_id {
+ PaneId::Terminal(terminal_pane_id) => {
+ // Try to get CWD from OS, fall back to cached value
+ self.id_to_child_pid
+ .get(terminal_pane_id)
+ .and_then(|&pid| {
+ self.bus
+ .os_input
+ .as_ref()
+ .and_then(|input| input.get_cwd(pid))
+ })
+ .or_else(|| self.terminal_cwds.get(terminal_pane_id).cloned())
+ },
+ PaneId::Plugin(plugin_id) => self.plugin_cwds.get(plugin_id).cloned(),
};
};
}