Improve completions inside of a pipeline

This commit is contained in:
JT 2021-09-10 20:07:18 +12:00
parent a8ba00b250
commit bfd05772ef
5 changed files with 16 additions and 7 deletions

View file

@ -40,6 +40,7 @@ impl Highlighter for NuHighlighter {
.to_string(); .to_string();
match shape.1 { match shape.1 {
FlatShape::External => output.push((Style::new().bold(), next_token)), FlatShape::External => output.push((Style::new().bold(), next_token)),
FlatShape::ExternalArg => output.push((Style::new().bold(), next_token)),
FlatShape::Garbage => output.push(( FlatShape::Garbage => output.push((
Style::new() Style::new()
.fg(nu_ansi_term::Color::White) .fg(nu_ansi_term::Color::White)

View file

@ -10,6 +10,7 @@ pub enum FlatShape {
Range, Range,
InternalCall, InternalCall,
External, External,
ExternalArg,
Literal, Literal,
Operator, Operator,
Signature, Signature,
@ -55,8 +56,14 @@ pub fn flatten_expression(
} }
output output
} }
Expr::ExternalCall(..) => { Expr::ExternalCall(name, args) => {
vec![(expr.span, FlatShape::External)] let mut output = vec![(*name, FlatShape::External)];
for arg in args {
output.push((*arg, FlatShape::ExternalArg));
}
output
} }
Expr::Garbage => { Expr::Garbage => {
vec![(expr.span, FlatShape::Garbage)] vec![(expr.span, FlatShape::Garbage)]

View file

@ -60,14 +60,14 @@ fn check_call(command: Span, sig: &Signature, call: &Call) -> Option<ParseError>
} }
pub fn parse_external_call( pub fn parse_external_call(
working_set: &mut StateWorkingSet, _working_set: &mut StateWorkingSet,
spans: &[Span], spans: &[Span],
) -> (Expression, Option<ParseError>) { ) -> (Expression, Option<ParseError>) {
// TODO: add external parsing // TODO: add external parsing
let mut args = vec![]; let mut args = vec![];
let name = working_set.get_span_contents(spans[0]).to_vec(); let name = spans[0];
for span in &spans[1..] { for span in &spans[1..] {
args.push(working_set.get_span_contents(*span).to_vec()); args.push(*span);
} }
( (
Expression { Expression {

View file

@ -13,7 +13,7 @@ pub enum Expr {
), ),
Var(VarId), Var(VarId),
Call(Box<Call>), Call(Box<Call>),
ExternalCall(Vec<u8>, Vec<Vec<u8>>), ExternalCall(Span, Vec<Span>),
Operator(Operator), Operator(Operator),
RowCondition(VarId, Box<Expression>), RowCondition(VarId, Box<Expression>),
BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs

View file

@ -685,6 +685,7 @@ impl WrappedTable {
); );
} }
} }
output.push('\n');
} }
SeparatorPosition::Middle => { SeparatorPosition::Middle => {
for column in self.column_widths.iter().enumerate() { for column in self.column_widths.iter().enumerate() {
@ -728,6 +729,7 @@ impl WrappedTable {
.push_str(&sep_color.paint(&self.theme.center.to_string()).to_string()); .push_str(&sep_color.paint(&self.theme.center.to_string()).to_string());
} }
} }
output.push('\n');
} }
SeparatorPosition::Bottom => { SeparatorPosition::Bottom => {
for column in self.column_widths.iter().enumerate() { for column in self.column_widths.iter().enumerate() {
@ -774,7 +776,6 @@ impl WrappedTable {
} }
} }
} }
output.push('\n');
output output
} }