Fix hiding of import patterns with globs (#487)

* Fix glob hiding

* Remove docs comment
This commit is contained in:
Jakub Žádník 2021-12-13 20:35:35 +02:00 committed by GitHub
parent 3701fd1d76
commit 930cb26e99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 11 deletions

View File

@ -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![];

View File

@ -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![];

View File

@ -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

View File

@ -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",
)
}