mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 00:54:23 +01:00
don't include import path in args to aliased external commands (#14231)
Fixes #13776 # User-Facing Changes Arguments to aliased externals no longer include nested import paths: ```diff module foo { export alias bar = ^echo } use foo foo bar baz -bar baz +baz ```
This commit is contained in:
parent
23fba6d2ea
commit
cc0259bbed
@ -1343,10 +1343,10 @@ pub fn parse_call(working_set: &mut StateWorkingSet, spans: &[Span], head: Span)
|
||||
trace!("parsing: alias of external call");
|
||||
|
||||
let mut head = head.clone();
|
||||
head.span = spans[0]; // replacing the spans preserves syntax highlighting
|
||||
head.span = Span::concat(&spans[cmd_start..pos]); // replacing the spans preserves syntax highlighting
|
||||
|
||||
let mut final_args = args.clone().into_vec();
|
||||
for arg_span in &spans[1..] {
|
||||
for arg_span in &spans[pos..] {
|
||||
let arg = parse_external_arg(working_set, *arg_span);
|
||||
final_args.push(arg);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ use nu_test_support::fs::Stub::{FileWithContent, FileWithContentToBeTrimmed};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, nu_repl_code};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
#[test]
|
||||
fn module_private_import_decl() {
|
||||
@ -612,6 +613,29 @@ fn deep_import_patterns() {
|
||||
assert_eq!(actual.out, "foo");
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn deep_import_aliased_external_args(
|
||||
#[values(
|
||||
"use spam; spam eggs beans foo bar",
|
||||
"use spam eggs; eggs beans foo bar",
|
||||
"use spam eggs beans; beans foo bar",
|
||||
"use spam eggs beans foo; foo bar"
|
||||
)]
|
||||
input: &str,
|
||||
) {
|
||||
let module_decl = "
|
||||
module spam {
|
||||
export module eggs {
|
||||
export module beans {
|
||||
export alias foo = ^echo
|
||||
}
|
||||
}
|
||||
}
|
||||
";
|
||||
let actual = nu!(format!("{module_decl}; {input}"));
|
||||
assert_eq!(actual.out, "bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_dir() {
|
||||
let import = "use samples/spam";
|
||||
|
Loading…
Reference in New Issue
Block a user