mirror of
https://github.com/nushell/nushell.git
synced 2024-12-24 07:59:21 +01:00
Add NU config to allow user be able to turn off external completion (#5773)
* 06-07-wsl * 06-07-linux-issue-with-delete-input * 06-08-2023 * 06-08-Linux * commit for merge * Fix unit test * format * clean code * Add flag to turn off external completion * change env var to config * Fix comment Co-authored-by: Frank Zhang <v-frankz@microsoft.com>
This commit is contained in:
parent
ff946a2f21
commit
534e1fc3ce
@ -199,12 +199,19 @@ impl Completer for CommandCompletion {
|
||||
return subcommands;
|
||||
}
|
||||
|
||||
let config = working_set.get_config();
|
||||
let commands = if matches!(self.flat_shape, nu_parser::FlatShape::External)
|
||||
|| matches!(self.flat_shape, nu_parser::FlatShape::InternalCall)
|
||||
|| ((span.end - span.start) == 0)
|
||||
{
|
||||
// we're in a gap or at a command
|
||||
self.complete_commands(working_set, span, offset, true, options.match_algorithm)
|
||||
self.complete_commands(
|
||||
working_set,
|
||||
span,
|
||||
offset,
|
||||
config.enable_external_completion,
|
||||
options.match_algorithm,
|
||||
)
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
@ -76,6 +76,7 @@ pub struct Config {
|
||||
pub disable_table_indexes: bool,
|
||||
pub cd_with_abbreviations: bool,
|
||||
pub case_sensitive_completions: bool,
|
||||
pub enable_external_completion: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -107,6 +108,7 @@ impl Default for Config {
|
||||
disable_table_indexes: false,
|
||||
cd_with_abbreviations: false,
|
||||
case_sensitive_completions: false,
|
||||
enable_external_completion: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,6 +325,13 @@ impl Value {
|
||||
eprintln!("$config.case_sensitive_completions is not a bool")
|
||||
}
|
||||
}
|
||||
"enable_external_completion" => {
|
||||
if let Ok(b) = value.as_bool() {
|
||||
config.enable_external_completion = b;
|
||||
} else {
|
||||
eprintln!("$config.enable_external_completion is not a bool")
|
||||
}
|
||||
}
|
||||
x => {
|
||||
eprintln!("$config.{} is an unknown config setting", x)
|
||||
}
|
||||
|
@ -219,6 +219,7 @@ let-env config = {
|
||||
disable_table_indexes: false # set to true to remove the index column from tables
|
||||
cd_with_abbreviations: false # set to true to allow you to do things like cd s/o/f and nushell expand it to cd some/other/folder
|
||||
case_sensitive_completions: false # set to true to enable case-sensitive completions
|
||||
enable_external_completion: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow
|
||||
|
||||
hooks: {
|
||||
pre_prompt: [{
|
||||
|
Loading…
Reference in New Issue
Block a user