mirror of
https://github.com/nushell/nushell
synced 2025-01-13 13:49:21 +00:00
Allow aliases to expand and ignore painting outside of lines (#3492)
This commit is contained in:
parent
1ee51f2afa
commit
41834d16d6
3 changed files with 19 additions and 1 deletions
|
@ -374,6 +374,10 @@ impl FromValue for Vec<Value> {
|
|||
value: UntaggedValue::Table(t),
|
||||
..
|
||||
} => Ok(t.clone()),
|
||||
Value {
|
||||
value: UntaggedValue::Row(_),
|
||||
..
|
||||
} => Ok(vec![v.clone()]),
|
||||
Value { tag, .. } => Err(ShellError::labeled_error(
|
||||
"Can't convert to table",
|
||||
"can't convert to table",
|
||||
|
|
|
@ -46,9 +46,11 @@ impl Painter {
|
|||
|
||||
fn paint(&mut self, styled_span: &Spanned<Style>) {
|
||||
for pos in styled_span.span.start()..styled_span.span.end() {
|
||||
if pos < self.styles.len() {
|
||||
self.styles[pos] = styled_span.item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn into_string(self) -> String {
|
||||
let mut idx_start = 0;
|
||||
|
|
|
@ -306,6 +306,18 @@ fn run_custom_command_with_empty_rest() {
|
|||
assert_eq!(actual.err, r#""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alias_a_load_env() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
def activate-helper [] { [[name, value]; [BOB, SAM]] }; alias activate = load-env (activate-helper); activate; $nu.env.BOB
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, r#"SAM"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn let_variable() {
|
||||
let actual = nu!(
|
||||
|
|
Loading…
Reference in a new issue