From 930cb26e99440ad205b7ffce72c5a6f85fa0e57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Mon, 13 Dec 2021 20:35:35 +0200 Subject: [PATCH] Fix hiding of import patterns with globs (#487) * Fix glob hiding * Remove docs comment --- crates/nu-command/src/core_commands/hide.rs | 4 +--- crates/nu-parser/src/parse_keywords.rs | 4 +--- docs/Modules_and_Overlays.md | 1 - src/tests.rs | 8 ++++---- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/nu-command/src/core_commands/hide.rs b/crates/nu-command/src/core_commands/hide.rs index 05fa5a252..26d143030 100644 --- a/crates/nu-command/src/core_commands/hide.rs +++ b/crates/nu-command/src/core_commands/hide.rs @@ -59,9 +59,7 @@ impl Command for Hide { overlay.env_vars_with_head(&import_pattern.head.name) } else { match &import_pattern.members[0] { - ImportPatternMember::Glob { .. } => { - overlay.env_vars_with_head(&import_pattern.head.name) - } + ImportPatternMember::Glob { .. } => overlay.env_vars(), ImportPatternMember::Name { name, span } => { let mut output = vec![]; diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 350c55918..a3253c1d3 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -866,9 +866,7 @@ pub fn parse_hide( } } else { match &import_pattern.members[0] { - ImportPatternMember::Glob { .. } => { - overlay.decls_with_head(&import_pattern.head.name) - } + ImportPatternMember::Glob { .. } => overlay.decls(), ImportPatternMember::Name { name, span } => { let mut output = vec![]; diff --git a/docs/Modules_and_Overlays.md b/docs/Modules_and_Overlays.md index a9ac38d68..781b06762 100644 --- a/docs/Modules_and_Overlays.md +++ b/docs/Modules_and_Overlays.md @@ -306,7 +306,6 @@ It creates the `$config` variable using the module system. ## Known Issues -* Hiding from a module needs to be improved: https://github.com/nushell/engine-q/issues/445 * It might be more appropriate to use `$scope.modules` instead of `$scope.overlays` ## Future Design Ideas diff --git a/src/tests.rs b/src/tests.rs index f8be6382d..eaffa9bcf 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -650,7 +650,7 @@ fn hides_def_import_1() -> TestResult { #[test] fn hides_def_import_2() -> TestResult { fail_test( - r#"module spam { export def foo [] { "foo" } }; use spam; hide spam *; spam foo"#, + r#"module spam { export def foo [] { "foo" } }; use spam; hide spam; spam foo"#, not_found_msg(), ) } @@ -682,7 +682,7 @@ fn hides_def_import_5() -> TestResult { #[test] fn hides_def_import_6() -> TestResult { fail_test( - r#"module spam { export def foo [] { "foo" } }; use spam; hide spam; spam foo"#, + r#"module spam { export def foo [] { "foo" } }; use spam *; hide spam *; foo"#, not_found_msg(), ) } @@ -698,7 +698,7 @@ fn hides_env_import_1() -> TestResult { #[test] fn hides_env_import_2() -> TestResult { fail_test( - r#"module spam { export env foo { "foo" } }; use spam; hide spam *; $nu.env.'spam foo'"#, + r#"module spam { export env foo { "foo" } }; use spam; hide spam; $nu.env.'spam foo'"#, "did you mean", ) } @@ -730,7 +730,7 @@ fn hides_env_import_5() -> TestResult { #[test] fn hides_env_import_6() -> TestResult { fail_test( - r#"module spam { export env foo { "foo" } }; use spam; hide spam; $nu.env.'spam foo'"#, + r#"module spam { export env foo { "foo" } }; use spam *; hide spam *; $nu.env.foo"#, "did you mean", ) }