mirror of
https://github.com/nushell/nushell.git
synced 2025-04-17 09:48:19 +02:00
Merge c506479c5a
into 885b87a842
This commit is contained in:
commit
3f38ecbe34
@ -30,9 +30,8 @@ impl Highlighter for NuHighlighter {
|
||||
// externals may slow down things too much.
|
||||
if highlight_resolved_externals {
|
||||
for (span, shape) in shapes.iter_mut() {
|
||||
if *shape == FlatShape::External {
|
||||
let str_contents =
|
||||
working_set.get_span_contents(Span::new(span.start, span.end));
|
||||
if let FlatShape::External(aliased_command_span) = *shape {
|
||||
let str_contents = working_set.get_span_contents(aliased_command_span);
|
||||
|
||||
let str_word = String::from_utf8_lossy(str_contents).to_string();
|
||||
let paths = env::path_str(&self.engine_state, &self.stack, *span).ok();
|
||||
@ -99,7 +98,7 @@ impl Highlighter for NuHighlighter {
|
||||
FlatShape::Float => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::Range => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::InternalCall(_) => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::External => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::External(_) => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::ExternalArg => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::ExternalResolved => add_colored_token(&shape.1, next_token),
|
||||
FlatShape::Keyword => add_colored_token(&shape.1, next_token),
|
||||
|
@ -1,3 +1,4 @@
|
||||
use core::str;
|
||||
use nu_protocol::{
|
||||
ast::{
|
||||
Argument, Block, Expr, Expression, ExternalArgument, ImportPatternMember, ListItem,
|
||||
@ -5,7 +6,7 @@ use nu_protocol::{
|
||||
RecordItem,
|
||||
},
|
||||
engine::StateWorkingSet,
|
||||
DeclId, Span, SyntaxShape, VarId,
|
||||
DeclId, GetSpan, Span, SyntaxShape, VarId,
|
||||
};
|
||||
use std::fmt::{Display, Formatter, Result};
|
||||
|
||||
@ -18,7 +19,7 @@ pub enum FlatShape {
|
||||
Custom(DeclId),
|
||||
DateTime,
|
||||
Directory,
|
||||
External,
|
||||
External(Span),
|
||||
ExternalArg,
|
||||
ExternalResolved,
|
||||
Filepath,
|
||||
@ -58,7 +59,7 @@ impl FlatShape {
|
||||
FlatShape::Custom(_) => "shape_custom",
|
||||
FlatShape::DateTime => "shape_datetime",
|
||||
FlatShape::Directory => "shape_directory",
|
||||
FlatShape::External => "shape_external",
|
||||
FlatShape::External(_) => "shape_external",
|
||||
FlatShape::ExternalArg => "shape_externalarg",
|
||||
FlatShape::ExternalResolved => "shape_external_resolved",
|
||||
FlatShape::Filepath => "shape_filepath",
|
||||
@ -326,7 +327,13 @@ fn flatten_expression_into(
|
||||
}
|
||||
Expr::ExternalCall(head, args) => {
|
||||
if let Expr::String(..) | Expr::GlobPattern(..) = &head.expr {
|
||||
output.push((head.span, FlatShape::External));
|
||||
output.push((
|
||||
head.span,
|
||||
// If this external call is through an alias, then head.span points to the
|
||||
// name of the alias, but we also need the name of the aliased command. We
|
||||
// recover this from the span referenced by head.span_id.
|
||||
FlatShape::External(working_set.get_span(head.span_id)),
|
||||
));
|
||||
} else {
|
||||
flatten_expression_into(working_set, head, output);
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ pub fn hover(engine_state: &mut EngineState, file_path: &str, location: &Value)
|
||||
}
|
||||
})
|
||||
),
|
||||
FlatShape::External => println!(
|
||||
FlatShape::External(_) => println!(
|
||||
"{}",
|
||||
json!({
|
||||
"hover": "external",
|
||||
|
Loading…
Reference in New Issue
Block a user