summaryrefslogtreecommitdiffstats
path: root/zellij-server/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-03-31 16:23:24 +0200
committerGitHub <noreply@github.com>2023-03-31 16:23:24 +0200
commitcc3c2765869e944a6e5d10ec3210935d8a18b9d8 (patch)
tree57faa25322fbe6f5e67e139fd10ff16ebf72c129 /zellij-server/src
parentdc03fb0318f4657d783cac7fbf2a7d0c5fd057b9 (diff)
fix(scrollback-editor): properly invoke editor when command includes spaces (#2339)
* fix(scrollback-editor): properly invoke editor when command includes spaces * style(fmt): srsly clippy?
Diffstat (limited to 'zellij-server/src')
-rw-r--r--zellij-server/src/os_input_output.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs
index 3c84d98af..18e8f92db 100644
--- a/zellij-server/src/os_input_output.rs
+++ b/zellij-server/src/os_input_output.rs
@@ -245,19 +245,22 @@ fn handle_terminal(
// this is a utility method to separate the arguments from a pathbuf before we turn it into a
// Command. eg. "/usr/bin/vim -e" ==> "/usr/bin/vim" + "-e" (the latter will be pushed to args)
fn separate_command_arguments(command: &mut PathBuf, args: &mut Vec<String>) {
- if let Some(file_name) = command
- .file_name()
- .and_then(|f_n| f_n.to_str())
- .map(|f_n| f_n.to_string())
- {
- let mut file_name_parts = file_name.split_ascii_whitespace();
- if let Some(first_part) = file_name_parts.next() {
- command.set_file_name(first_part);
- for part in file_name_parts {
- args.push(String::from(part));
- }
+ let mut parts = vec![];
+ let mut current_part = String::new();
+ for part in command.display().to_string().split_ascii_whitespace() {
+ current_part.push_str(part);
+ if current_part.ends_with('\\') {
+ let _ = current_part.pop();
+ current_part.push(' ');
+ } else {
+ let current_part = std::mem::replace(&mut current_part, String::new());
+ parts.push(current_part);
}
}
+ if !parts.is_empty() {
+ *command = PathBuf::from(parts.remove(0));
+ args.append(&mut parts);
+ }
}
/// If a [`TerminalAction::OpenFile(file)`] is given, the text editor specified by environment variable `EDITOR`