summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-11-16 16:25:01 +0100
committerGitHub <noreply@github.com>2022-11-16 16:25:01 +0100
commitcc3ac25c74284d3ad834180891fc072502548c74 (patch)
tree22d689cdf971566dd60bf609131496c087782d08 /zellij-utils
parented64cff9b505b589136352e605c19cc30082eb46 (diff)
fix(cli): measure cwd from cli client rather than the zellij server (#1947)
* fix(cli): measure cwd from cli client rather than the zellij server * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/src/input/actions.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index e0337da09..e62a6ec62 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -228,7 +228,10 @@ pub enum Action {
}
impl Action {
- pub fn actions_from_cli(cli_action: CliAction) -> Result<Vec<Action>, String> {
+ pub fn actions_from_cli(
+ cli_action: CliAction,
+ get_current_dir: Box<dyn Fn() -> PathBuf>,
+ ) -> Result<Vec<Action>, String> {
match cli_action {
CliAction::Write { bytes } => Ok(vec![Action::Write(bytes)]),
CliAction::WriteChars { chars } => Ok(vec![Action::WriteChars(chars)]),
@@ -265,7 +268,10 @@ impl Action {
if !command.is_empty() {
let mut command = command.clone();
let (command, args) = (PathBuf::from(command.remove(0)), command);
- let cwd = cwd.or_else(|| std::env::current_dir().ok());
+ let current_dir = get_current_dir();
+ let cwd = cwd
+ .map(|cwd| current_dir.join(cwd))
+ .or_else(|| Some(current_dir));
let hold_on_start = start_suspended;
let hold_on_close = !close_on_exit;
let run_command_action = RunCommandAction {
@@ -304,7 +310,10 @@ impl Action {
cwd,
} => {
let mut file = file;
- let cwd = cwd.or_else(|| std::env::current_dir().ok());
+ let current_dir = get_current_dir();
+ let cwd = cwd
+ .map(|cwd| current_dir.join(cwd))
+ .or_else(|| Some(current_dir));
if file.is_relative() {
if let Some(cwd) = cwd {
file = cwd.join(file);
@@ -338,6 +347,10 @@ impl Action {
]),
CliAction::UndoRenameTab => Ok(vec![Action::UndoRenameTab]),
CliAction::NewTab { name, layout, cwd } => {
+ let current_dir = get_current_dir();
+ let cwd = cwd
+ .map(|cwd| current_dir.join(cwd))
+ .or_else(|| Some(current_dir));
if let Some(layout_path) = layout {
let (path_to_raw_layout, raw_layout) =
Layout::stringified_from_path_or_default(Some(&layout_path), None)