fix(plugins): various cwd fixes (#3545)
* fix(plugins): various cwd fixes * fix tests
This commit is contained in:
parent
47caeb66a6
commit
8080050aac
4 changed files with 20 additions and 5 deletions
|
|
@ -6873,5 +6873,9 @@ pub fn open_command_pane_background_plugin_command() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.clone();
|
.clone();
|
||||||
assert_snapshot!(format!("{:#?}", new_tab_event));
|
// we do the replace below to avoid the randomness of the temporary folder in the snapshot
|
||||||
|
// while still testing it
|
||||||
|
assert_snapshot!(
|
||||||
|
format!("{:#?}", new_tab_event).replace(&format!("{:?}", temp_folder.path()), "\"CWD\"")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
source: zellij-server/src/plugins/./unit/plugin_tests.rs
|
||||||
assertion_line: 6876
|
assertion_line: 6878
|
||||||
expression: "format!(\"{:#?}\", new_tab_event)"
|
expression: "format!(\"{:#?}\",\n new_tab_event).replace(&format!(\"{:?}\", temp_folder.path()),\n \"\\\"CWD\\\"\")"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
SpawnTerminal(
|
SpawnTerminal(
|
||||||
|
|
@ -13,7 +13,9 @@ Some(
|
||||||
"arg1",
|
"arg1",
|
||||||
"arg2",
|
"arg2",
|
||||||
],
|
],
|
||||||
cwd: None,
|
cwd: Some(
|
||||||
|
"CWD",
|
||||||
|
),
|
||||||
hold_on_close: true,
|
hold_on_close: true,
|
||||||
hold_on_start: false,
|
hold_on_start: false,
|
||||||
originating_plugin: Some(
|
originating_plugin: Some(
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,10 @@ fn open_command_pane_background(
|
||||||
context: BTreeMap<String, String>,
|
context: BTreeMap<String, String>,
|
||||||
) {
|
) {
|
||||||
let command = command_to_run.path;
|
let command = command_to_run.path;
|
||||||
let cwd = command_to_run.cwd.map(|cwd| env.plugin_cwd.join(cwd));
|
let cwd = command_to_run
|
||||||
|
.cwd
|
||||||
|
.map(|cwd| env.plugin_cwd.join(cwd))
|
||||||
|
.or_else(|| Some(env.plugin_cwd.clone()));
|
||||||
let args = command_to_run.args;
|
let args = command_to_run.args;
|
||||||
let direction = None;
|
let direction = None;
|
||||||
let hold_on_close = true;
|
let hold_on_close = true;
|
||||||
|
|
|
||||||
|
|
@ -1177,6 +1177,9 @@ impl<'a> KdlLayoutParser<'a> {
|
||||||
};
|
};
|
||||||
if let Some(cwd_prefix) = &self.cwd_prefix(tab_cwd.as_ref())? {
|
if let Some(cwd_prefix) = &self.cwd_prefix(tab_cwd.as_ref())? {
|
||||||
pane_layout.add_cwd_to_layout(&cwd_prefix);
|
pane_layout.add_cwd_to_layout(&cwd_prefix);
|
||||||
|
for floating_pane in child_floating_panes.iter_mut() {
|
||||||
|
floating_pane.add_cwd_to_layout(&cwd_prefix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok((is_focused, tab_name, pane_layout, child_floating_panes))
|
Ok((is_focused, tab_name, pane_layout, child_floating_panes))
|
||||||
}
|
}
|
||||||
|
|
@ -1583,6 +1586,9 @@ impl<'a> KdlLayoutParser<'a> {
|
||||||
}
|
}
|
||||||
if let Some(cwd_prefix) = self.cwd_prefix(tab_cwd.as_ref())? {
|
if let Some(cwd_prefix) = self.cwd_prefix(tab_cwd.as_ref())? {
|
||||||
tab_layout.add_cwd_to_layout(&cwd_prefix);
|
tab_layout.add_cwd_to_layout(&cwd_prefix);
|
||||||
|
for floating_pane in tab_template_floating_panes.iter_mut() {
|
||||||
|
floating_pane.add_cwd_to_layout(&cwd_prefix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tab_layout.external_children_index = None;
|
tab_layout.external_children_index = None;
|
||||||
Ok((
|
Ok((
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue