diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-08-07 13:46:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-07 13:46:08 +0200 |
| commit | 8080050aacd50eaafcaec92f52a7e5d3e640b865 (patch) | |
| tree | 42851785b85d25645d88ba95041e99649d70fee9 | |
| parent | docs(changelog): background command panes (diff) | |
| download | sl0ppij-8080050aacd50eaafcaec92f52a7e5d3e640b865.tar.gz sl0ppij-8080050aacd50eaafcaec92f52a7e5d3e640b865.tar.xz sl0ppij-8080050aacd50eaafcaec92f52a7e5d3e640b865.zip | |
fix(plugins): various cwd fixes (#3545)
* fix(plugins): various cwd fixes
* fix tests
4 files changed, 20 insertions, 5 deletions
diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs index 031f0100..f3a6fed8 100644 --- a/zellij-server/src/plugins/unit/plugin_tests.rs +++ b/zellij-server/src/plugins/unit/plugin_tests.rs @@ -6873,5 +6873,9 @@ pub fn open_command_pane_background_plugin_command() { } }) .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\"") + ); } diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_background_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_background_plugin_command.snap index 8c86f8f3..e8cb7daf 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_background_plugin_command.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__open_command_pane_background_plugin_command.snap @@ -1,7 +1,7 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 6876 -expression: "format!(\"{:#?}\", new_tab_event)" +assertion_line: 6878 +expression: "format!(\"{:#?}\",\n new_tab_event).replace(&format!(\"{:?}\", temp_folder.path()),\n \"\\\"CWD\\\"\")" --- Some( SpawnTerminal( @@ -13,7 +13,9 @@ Some( "arg1", "arg2", ], - cwd: None, + cwd: Some( + "CWD", + ), hold_on_close: true, hold_on_start: false, originating_plugin: Some( diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs index 4f7f04b6..6c737b41 100644 --- a/zellij-server/src/plugins/zellij_exports.rs +++ b/zellij-server/src/plugins/zellij_exports.rs @@ -660,7 +660,10 @@ fn open_command_pane_background( context: BTreeMap<String, String>, ) { 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 direction = None; let hold_on_close = true; diff --git a/zellij-utils/src/kdl/kdl_layout_parser.rs b/zellij-utils/src/kdl/kdl_layout_parser.rs index f19cc9a2..81e97a7e 100644 --- a/zellij-utils/src/kdl/kdl_layout_parser.rs +++ b/zellij-utils/src/kdl/kdl_layout_parser.rs @@ -1177,6 +1177,9 @@ impl<'a> KdlLayoutParser<'a> { }; if let Some(cwd_prefix) = &self.cwd_prefix(tab_cwd.as_ref())? { 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)) } @@ -1583,6 +1586,9 @@ impl<'a> KdlLayoutParser<'a> { } if let Some(cwd_prefix) = self.cwd_prefix(tab_cwd.as_ref())? { 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; Ok(( |
