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),
|
value: UntaggedValue::Table(t),
|
||||||
..
|
..
|
||||||
} => Ok(t.clone()),
|
} => Ok(t.clone()),
|
||||||
|
Value {
|
||||||
|
value: UntaggedValue::Row(_),
|
||||||
|
..
|
||||||
|
} => Ok(vec![v.clone()]),
|
||||||
Value { tag, .. } => Err(ShellError::labeled_error(
|
Value { tag, .. } => Err(ShellError::labeled_error(
|
||||||
"Can't convert to table",
|
"Can't convert to table",
|
||||||
"can't convert to table",
|
"can't convert to table",
|
||||||
|
|
|
@ -46,7 +46,9 @@ impl Painter {
|
||||||
|
|
||||||
fn paint(&mut self, styled_span: &Spanned<Style>) {
|
fn paint(&mut self, styled_span: &Spanned<Style>) {
|
||||||
for pos in styled_span.span.start()..styled_span.span.end() {
|
for pos in styled_span.span.start()..styled_span.span.end() {
|
||||||
self.styles[pos] = styled_span.item;
|
if pos < self.styles.len() {
|
||||||
|
self.styles[pos] = styled_span.item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,18 @@ fn run_custom_command_with_empty_rest() {
|
||||||
assert_eq!(actual.err, r#""#);
|
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]
|
#[test]
|
||||||
fn let_variable() {
|
fn let_variable() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
|
Loading…
Reference in a new issue