fix(plugins): respect default shell when configured in the $SHELL env variable (#3296)

* fix(plugins): respect $SHELL alias for default shell

* style(fmt): rustfmt

* fix tests
This commit is contained in:
Aram Drevekenin 2024-04-24 15:39:54 +02:00 committed by GitHub
parent fca7a209d2
commit 5e587333b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 19 deletions

View File

@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4246
assertion_line: 4390
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@ -8,7 +8,7 @@ Some(
Some(
RunCommand(
RunCommand {
command: "",
command: ".",
args: [],
cwd: Some(
"/path/to/my/file.rs",

View File

@ -1,6 +1,6 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4169
assertion_line: 4312
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
@ -8,7 +8,7 @@ Some(
Some(
RunCommand(
RunCommand {
command: "",
command: ".",
args: [],
cwd: Some(
"/path/to/my/file.rs",

View File

@ -515,11 +515,12 @@ fn open_file_in_place(env: &ForeignFunctionEnv, file_to_open: FileToOpen) {
fn open_terminal(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),
@ -536,11 +537,12 @@ fn open_terminal_floating(
) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),
@ -553,11 +555,12 @@ fn open_terminal_floating(
fn open_terminal_in_place(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),