mirror of
https://github.com/nushell/nushell.git
synced 2025-05-08 12:04:25 +02:00
fix(completion): completions.external.enable config option not respected (#15443)
Fixes #15441 # Description Actually I made a small change to the original behavior: ``` ^foo<tab> ``` will still show external commands, regardless of whether it's enabled or not. I think that's the only thing people want to see when they press tab with a `^` prefix. # User-Facing Changes # Tests + Formatting +1 # After Submitting Should I document that minor behavior change somewhere in GitHub.io? --------- Co-authored-by: Yash Thakur <45539777+ysthakur@users.noreply.github.com>
This commit is contained in:
parent
2bad1371f0
commit
5fe97b8d59
@ -486,9 +486,10 @@ impl NuCompleter {
|
||||
externals: bool,
|
||||
strip: bool,
|
||||
) -> Vec<SemanticSuggestion> {
|
||||
let config = self.engine_state.get_config();
|
||||
let mut command_completions = CommandCompletion {
|
||||
internals,
|
||||
externals,
|
||||
externals: !internals || (externals && config.completions.external.enable),
|
||||
};
|
||||
let (new_span, prefix) = strip_placeholder_if_any(working_set, &span, strip);
|
||||
let ctx = Context::new(working_set, new_span, prefix, offset);
|
||||
|
@ -10,7 +10,7 @@ use nu_cli::NuCompleter;
|
||||
use nu_engine::eval_block;
|
||||
use nu_parser::parse;
|
||||
use nu_path::expand_tilde;
|
||||
use nu_protocol::{debugger::WithoutDebug, engine::StateWorkingSet, PipelineData};
|
||||
use nu_protocol::{debugger::WithoutDebug, engine::StateWorkingSet, Config, PipelineData};
|
||||
use reedline::{Completer, Suggestion};
|
||||
use rstest::{fixture, rstest};
|
||||
use support::{
|
||||
@ -367,7 +367,7 @@ export def say [
|
||||
|
||||
/// External command only if starts with `^`
|
||||
#[test]
|
||||
fn external_commands_only() {
|
||||
fn external_commands() {
|
||||
let engine = new_external_engine();
|
||||
let mut completer = NuCompleter::new(
|
||||
Arc::new(engine),
|
||||
@ -390,6 +390,31 @@ fn external_commands_only() {
|
||||
match_suggestions(&expected, &suggestions);
|
||||
}
|
||||
|
||||
/// Disable external commands except for those start with `^`
|
||||
#[test]
|
||||
fn external_commands_disabled() {
|
||||
let mut engine = new_external_engine();
|
||||
|
||||
let mut config = Config::default();
|
||||
config.completions.external.enable = false;
|
||||
engine.set_config(config);
|
||||
|
||||
let stack = nu_protocol::engine::Stack::new();
|
||||
let mut completer = NuCompleter::new(Arc::new(engine), Arc::new(stack));
|
||||
let completion_str = "ls; ^sleep";
|
||||
let suggestions = completer.complete(completion_str, completion_str.len());
|
||||
#[cfg(windows)]
|
||||
let expected: Vec<_> = vec!["sleep.exe"];
|
||||
#[cfg(not(windows))]
|
||||
let expected: Vec<_> = vec!["sleep"];
|
||||
match_suggestions(&expected, &suggestions);
|
||||
|
||||
let completion_str = "sleep";
|
||||
let suggestions = completer.complete(completion_str, completion_str.len());
|
||||
let expected: Vec<_> = vec!["sleep"];
|
||||
match_suggestions(&expected, &suggestions);
|
||||
}
|
||||
|
||||
/// Which completes both internals and externals
|
||||
#[test]
|
||||
fn which_command_completions() {
|
||||
|
Loading…
Reference in New Issue
Block a user