mirror of
https://github.com/nushell/nushell.git
synced 2025-01-09 07:48:14 +01:00
cleanup some highlighting
This commit is contained in:
parent
7cac5bb633
commit
184125a70a
@ -216,7 +216,7 @@ pub fn eval_expression(
|
|||||||
Ok(Value::List(output))
|
Ok(Value::List(output))
|
||||||
}
|
}
|
||||||
Expr::Table(_, _) => Err(ShellError::Unsupported(expr.span)),
|
Expr::Table(_, _) => Err(ShellError::Unsupported(expr.span)),
|
||||||
Expr::Keyword(_, expr) => eval_expression(state, stack, expr),
|
Expr::Keyword(_, _, expr) => eval_expression(state, stack, expr),
|
||||||
Expr::String(s) => Ok(Value::String {
|
Expr::String(s) => Ok(Value::String {
|
||||||
val: s.clone(),
|
val: s.clone(),
|
||||||
span: expr.span,
|
span: expr.span,
|
||||||
|
@ -43,9 +43,20 @@ impl<'a> ParserWorkingSet<'a> {
|
|||||||
Expr::Block(block_id) => self.flatten_block(self.get_block(*block_id)),
|
Expr::Block(block_id) => self.flatten_block(self.get_block(*block_id)),
|
||||||
Expr::Call(call) => {
|
Expr::Call(call) => {
|
||||||
let mut output = vec![(call.head, FlatShape::InternalCall)];
|
let mut output = vec![(call.head, FlatShape::InternalCall)];
|
||||||
|
let mut last_span = call.head.end;
|
||||||
for positional in &call.positional {
|
for positional in &call.positional {
|
||||||
|
last_span = positional.span.end;
|
||||||
output.extend(self.flatten_expression(positional));
|
output.extend(self.flatten_expression(positional));
|
||||||
}
|
}
|
||||||
|
if last_span < expr.span.end {
|
||||||
|
output.push((
|
||||||
|
Span {
|
||||||
|
start: last_span,
|
||||||
|
end: expr.span.end,
|
||||||
|
},
|
||||||
|
FlatShape::InternalCall,
|
||||||
|
));
|
||||||
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
Expr::ExternalCall(..) => {
|
Expr::ExternalCall(..) => {
|
||||||
@ -68,7 +79,11 @@ impl<'a> ParserWorkingSet<'a> {
|
|||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
Expr::Keyword(_, expr) => self.flatten_expression(expr),
|
Expr::Keyword(_, span, expr) => {
|
||||||
|
let mut output = vec![(*span, FlatShape::Operator)];
|
||||||
|
output.extend(self.flatten_expression(expr));
|
||||||
|
output
|
||||||
|
}
|
||||||
Expr::Operator(_) => {
|
Expr::Operator(_) => {
|
||||||
vec![(expr.span, FlatShape::Operator)]
|
vec![(expr.span, FlatShape::Operator)]
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ pub enum Expr {
|
|||||||
Block(BlockId),
|
Block(BlockId),
|
||||||
List(Vec<Expression>),
|
List(Vec<Expression>),
|
||||||
Table(Vec<Expression>, Vec<Vec<Expression>>),
|
Table(Vec<Expression>, Vec<Vec<Expression>>),
|
||||||
Keyword(Vec<u8>, Box<Expression>),
|
Keyword(Vec<u8>, Span, Box<Expression>),
|
||||||
String(String), // FIXME: improve this in the future?
|
String(String), // FIXME: improve this in the future?
|
||||||
Signature(Box<Signature>),
|
Signature(Box<Signature>),
|
||||||
Garbage,
|
Garbage,
|
||||||
@ -241,7 +241,7 @@ impl Expression {
|
|||||||
|
|
||||||
pub fn as_keyword(&self) -> Option<&Expression> {
|
pub fn as_keyword(&self) -> Option<&Expression> {
|
||||||
match &self.expr {
|
match &self.expr {
|
||||||
Expr::Keyword(_, expr) => Some(expr),
|
Expr::Keyword(_, _, expr) => Some(expr),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -646,6 +646,7 @@ impl<'a> ParserWorkingSet<'a> {
|
|||||||
Expression {
|
Expression {
|
||||||
expr: Expr::Keyword(
|
expr: Expr::Keyword(
|
||||||
keyword.clone(),
|
keyword.clone(),
|
||||||
|
spans[*spans_idx - 1],
|
||||||
Box::new(Expression::garbage(arg_span)),
|
Box::new(Expression::garbage(arg_span)),
|
||||||
),
|
),
|
||||||
span: arg_span,
|
span: arg_span,
|
||||||
@ -660,7 +661,7 @@ impl<'a> ParserWorkingSet<'a> {
|
|||||||
|
|
||||||
(
|
(
|
||||||
Expression {
|
Expression {
|
||||||
expr: Expr::Keyword(keyword.clone(), Box::new(expr)),
|
expr: Expr::Keyword(keyword.clone(), spans[*spans_idx - 1], Box::new(expr)),
|
||||||
span: arg_span,
|
span: arg_span,
|
||||||
ty,
|
ty,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user