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?
This commit is contained in:
parent
dc03fb0318
commit
cc3c276586
1 changed files with 14 additions and 11 deletions
|
|
@ -245,18 +245,21 @@ fn handle_terminal(
|
||||||
// this is a utility method to separate the arguments from a pathbuf before we turn it into a
|
// 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)
|
// 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>) {
|
fn separate_command_arguments(command: &mut PathBuf, args: &mut Vec<String>) {
|
||||||
if let Some(file_name) = command
|
let mut parts = vec![];
|
||||||
.file_name()
|
let mut current_part = String::new();
|
||||||
.and_then(|f_n| f_n.to_str())
|
for part in command.display().to_string().split_ascii_whitespace() {
|
||||||
.map(|f_n| f_n.to_string())
|
current_part.push_str(part);
|
||||||
{
|
if current_part.ends_with('\\') {
|
||||||
let mut file_name_parts = file_name.split_ascii_whitespace();
|
let _ = current_part.pop();
|
||||||
if let Some(first_part) = file_name_parts.next() {
|
current_part.push(' ');
|
||||||
command.set_file_name(first_part);
|
} else {
|
||||||
for part in file_name_parts {
|
let current_part = std::mem::replace(&mut current_part, String::new());
|
||||||
args.push(String::from(part));
|
parts.push(current_part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !parts.is_empty() {
|
||||||
|
*command = PathBuf::from(parts.remove(0));
|
||||||
|
args.append(&mut parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue