summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-02-07 10:39:51 +0100
committerGitHub <noreply@github.com>2024-02-07 10:39:51 +0100
commit7e549cdbd5e0df712419802f2d2517f82c34e4a7 (patch)
tree80e9073edefac6c4cf45b9dcbdc663dba3206ad8 /zellij-utils/src
parent5e364940fde45631a6ede344d9839240b34c5a62 (diff)
fix(cli): respect cwd in zellij run and zellij plugin (#3116)
* fix(cli): respect cwd in zellij run and zellij plugin commands * style(fmt): rustfmt * fix tests
Diffstat (limited to 'zellij-utils/src')
-rw-r--r--zellij-utils/src/input/actions.rs22
-rw-r--r--zellij-utils/src/kdl/mod.rs2
-rw-r--r--zellij-utils/src/plugin_api/action.rs8
3 files changed, 21 insertions, 11 deletions
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 74c6c1e2e..7ec508795 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -213,8 +213,8 @@ pub enum Action {
MiddleClick(Position),
LaunchOrFocusPlugin(RunPlugin, bool, bool, bool, bool), // bools => should float,
// move_to_focused_tab, should_open_in_place, skip_cache
- LaunchPlugin(RunPlugin, bool, bool, bool), // bools => should float,
- // should_open_in_place, skip_cache
+ LaunchPlugin(RunPlugin, bool, bool, bool, Option<PathBuf>), // bools => should float,
+ // should_open_in_place, skip_cache, Option<PathBuf> is cwd
LeftMouseRelease(Position),
RightMouseRelease(Position),
MiddleMouseRelease(Position),
@@ -240,10 +240,10 @@ pub enum Action {
/// Query all tab names
QueryTabNames,
/// Open a new tiled (embedded, non-floating) plugin pane
- NewTiledPluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
- // skip_cache
- NewFloatingPluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
- // skip_cache
+ NewTiledPluginPane(RunPlugin, Option<String>, bool, Option<PathBuf>), // String is an optional name, bool is
+ // skip_cache, Option<PathBuf> is cwd
+ NewFloatingPluginPane(RunPlugin, Option<String>, bool, Option<PathBuf>), // String is an optional name, bool is
+ // skip_cache, Option<PathBuf> is cwd
NewInPlacePluginPane(RunPlugin, Option<String>, bool), // String is an optional name, bool is
// skip_cache
StartOrReloadPlugin(RunPlugin),
@@ -337,7 +337,7 @@ impl Action {
.or_else(|| Some(current_dir));
let user_configuration = configuration.unwrap_or_default();
if let Some(plugin) = plugin {
- let location = RunPluginLocation::parse(&plugin, cwd)
+ let location = RunPluginLocation::parse(&plugin, cwd.clone())
.map_err(|e| format!("Failed to parse plugin loction {plugin}: {}", e))?;
let plugin = RunPlugin {
_allow_exec_host_cmd: false,
@@ -349,6 +349,7 @@ impl Action {
plugin,
name,
skip_plugin_cache,
+ cwd,
)])
} else if in_place {
Ok(vec![Action::NewInPlacePluginPane(
@@ -369,6 +370,7 @@ impl Action {
plugin,
name,
skip_plugin_cache,
+ cwd,
)])
}
} else if !command.is_empty() {
@@ -583,8 +585,9 @@ impl Action {
skip_plugin_cache,
} => {
let current_dir = get_current_dir();
- let run_plugin_location = RunPluginLocation::parse(url.as_str(), Some(current_dir))
- .map_err(|e| format!("Failed to parse plugin location: {}", e))?;
+ let run_plugin_location =
+ RunPluginLocation::parse(url.as_str(), Some(current_dir.clone()))
+ .map_err(|e| format!("Failed to parse plugin location: {}", e))?;
let run_plugin = RunPlugin {
location: run_plugin_location,
_allow_exec_host_cmd: false,
@@ -595,6 +598,7 @@ impl Action {
floating,
in_place,
skip_plugin_cache,
+ Some(current_dir),
)])
},
CliAction::RenameSession { name } => Ok(vec![Action::RenameSession(name)]),
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index e911f391e..95d52007b 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -992,6 +992,8 @@ impl TryFrom<(&KdlNode, &Options)> for Action {
should_float,
should_open_in_place,
skip_plugin_cache,
+ None, // we explicitly do not send the current dir here so that it will be
+ // filled from the active pane == better UX
))
},
"PreviousSwapLayout" => Ok(Action::PreviousSwapLayout),
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs
index 82de4c7ee..e97c24334 100644
--- a/zellij-utils/src/plugin_api/action.rs
+++ b/zellij-utils/src/plugin_api/action.rs
@@ -439,6 +439,7 @@ impl TryFrom<ProtobufAction> for Action {
should_float,
should_open_in_place,
skip_plugin_cache,
+ None,
))
},
_ => Err("Wrong payload for Action::LaunchOrFocusPlugin"),
@@ -548,6 +549,7 @@ impl TryFrom<ProtobufAction> for Action {
run_plugin,
pane_name,
skip_plugin_cache,
+ None,
))
},
_ => Err("Wrong payload for Action::NewTiledPluginPane"),
@@ -570,6 +572,7 @@ impl TryFrom<ProtobufAction> for Action {
run_plugin,
pane_name,
skip_plugin_cache,
+ None,
))
},
_ => Err("Wrong payload for Action::MiddleClick"),
@@ -1043,6 +1046,7 @@ impl TryFrom<Action> for ProtobufAction {
should_float,
should_open_in_place,
skip_plugin_cache,
+ cwd,
) => {
let url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
@@ -1137,7 +1141,7 @@ impl TryFrom<Action> for ProtobufAction {
name: ProtobufActionName::QueryTabNames as i32,
optional_payload: None,
}),
- Action::NewTiledPluginPane(run_plugin, pane_name, skip_plugin_cache) => {
+ Action::NewTiledPluginPane(run_plugin, pane_name, skip_plugin_cache, _cwd) => {
let plugin_url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
name: ProtobufActionName::NewTiledPluginPane as i32,
@@ -1150,7 +1154,7 @@ impl TryFrom<Action> for ProtobufAction {
)),
})
},
- Action::NewFloatingPluginPane(run_plugin, pane_name, skip_plugin_cache) => {
+ Action::NewFloatingPluginPane(run_plugin, pane_name, skip_plugin_cache, _cwd) => {
let plugin_url: Url = Url::from(&run_plugin.location);
Ok(ProtobufAction {
name: ProtobufActionName::NewFloatingPluginPane as i32,