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();
match shape.1 {
FlatShape::External => output.push((Style::new().bold(), next_token)),
FlatShape::ExternalArg => output.push((Style::new().bold(), next_token)),
FlatShape::Garbage => output.push((
Style::new()
.fg(nu_ansi_term::Color::White)

View file

@ -10,6 +10,7 @@ pub enum FlatShape {
Range,
InternalCall,
External,
ExternalArg,
Literal,
Operator,
Signature,
@ -55,8 +56,14 @@ pub fn flatten_expression(
}
output
}
Expr::ExternalCall(..) => {
vec![(expr.span, FlatShape::External)]
Expr::ExternalCall(name, args) => {
let mut output = vec![(*name, FlatShape::External)];
for arg in args {
output.push((*arg, FlatShape::ExternalArg));
}
output
}
Expr::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(
working_set: &mut StateWorkingSet,
_working_set: &mut StateWorkingSet,
spans: &[Span],
) -> (Expression, Option<ParseError>) {
// TODO: add external parsing
let mut args = vec![];
let name = working_set.get_span_contents(spans[0]).to_vec();
let name = spans[0];
for span in &spans[1..] {
args.push(working_set.get_span_contents(*span).to_vec());
args.push(*span);
}
(
Expression {

View file

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

View file

@ -685,6 +685,7 @@ impl WrappedTable {
);
}
}
output.push('\n');
}
SeparatorPosition::Middle => {
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());
}
}
output.push('\n');
}
SeparatorPosition::Bottom => {
for column in self.column_widths.iter().enumerate() {
@ -774,7 +776,6 @@ impl WrappedTable {
}
}
}
output.push('\n');
output
}