mirror of
https://github.com/nushell/nushell.git
synced 2025-02-14 17:40:12 +01:00
# Description This merges @horasal 's changes from #10246 and #10269 Closes #10205 Closes #8714 Fixes the bug that editor paths with spaces are unusable Closes #10210 Closes #10269 # User-Facing Changes You can now either pass a string with the name of the executable or a list with the executable and any flags to `$env.config.buffer_editor`/`$env.EDITOR`/`$env.VISUAL` Both the external buffer editor of reedline (by default bound to `Ctrl-o`) and the commands `config nu` and `config env` will respect those variables in the following order: 1. `$env.config.buffer_editor` 2. `$env.EDITOR` 3. `$env.VISUAL` Example: ``` $env.EDITOR = "nvim" # The system-wide EDITOR is neovim $env.config.buffer_editor = ["vim" "-p2"] # Force vim to open two tabs (not particularly useful) $env.config.buffer_editor = null # Unset `buffer_editor` -> Uses `$env.EDITOR` ergo nvim ``` # Tests + Formatting None --------- Co-authored-by: Horasal <1991933+horasal@users.noreply.github.com>
42 lines
927 B
Rust
42 lines
927 B
Rust
use std::collections::HashMap;
|
|
use std::path::PathBuf;
|
|
|
|
use nu_protocol::{Span, Spanned};
|
|
|
|
use crate::ExternalCommand;
|
|
|
|
pub(crate) fn gen_command(
|
|
span: Span,
|
|
config_path: PathBuf,
|
|
item: String,
|
|
config_args: Vec<String>,
|
|
env_vars_str: HashMap<String, String>,
|
|
) -> ExternalCommand {
|
|
let name = Spanned { item, span };
|
|
|
|
let mut args = vec![Spanned {
|
|
item: config_path.to_string_lossy().to_string(),
|
|
span: Span::unknown(),
|
|
}];
|
|
|
|
let number_of_args = config_args.len() + 1;
|
|
|
|
for arg in config_args {
|
|
args.push(Spanned {
|
|
item: arg,
|
|
span: Span::unknown(),
|
|
})
|
|
}
|
|
|
|
ExternalCommand {
|
|
name,
|
|
args,
|
|
arg_keep_raw: vec![false; number_of_args],
|
|
redirect_stdout: false,
|
|
redirect_stderr: false,
|
|
redirect_combine: false,
|
|
env_vars: env_vars_str,
|
|
trim_end_newline: false,
|
|
}
|
|
}
|