Merge pull request #41 from nushell/fix_inner_completions

Improve completions inside of a pipeline
This commit is contained in:
JT 2021-09-10 20:10:17 +12:00 committed by GitHub
commit 2d3a56f0d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}