forked from extern/nushell
Add method to convert ClassifiedBlock into completion locations. (#2316)
The completion engine maps completion locations to spans on a line, which indicate whther to complete a command name, flag name, argument, and so on. Initial implementation is simplistic, with some rough edges, since it relies heavily on the parser's interpretation. For example du - if asking for completions, `-` is considered a positional argument by the parser, but the user is likely looking for a flag. These scenarios will be addressed in a series of progressive enhancements to the engine.
This commit is contained in:
@ -4,10 +4,10 @@ use std::fmt::Debug;
|
||||
#[derive(Debug)]
|
||||
pub struct ParseError<T: Debug> {
|
||||
/// An informative cause for this parse error
|
||||
pub(crate) cause: nu_errors::ParseError,
|
||||
pub cause: nu_errors::ParseError,
|
||||
|
||||
/// What has been successfully parsed, if anything
|
||||
pub(crate) partial: Option<T>,
|
||||
pub partial: Option<T>,
|
||||
}
|
||||
|
||||
pub type ParseResult<T> = Result<T, ParseError<T>>;
|
||||
|
@ -133,11 +133,6 @@ fn bare(src: &mut Input, span_offset: usize) -> ParseResult<Spanned<String>> {
|
||||
// correct information from the non-lite parse.
|
||||
bare.push(delimiter);
|
||||
|
||||
let span = Span::new(
|
||||
start_offset + span_offset,
|
||||
start_offset + span_offset + bare.len(),
|
||||
);
|
||||
|
||||
return Err(ParseError {
|
||||
cause: nu_errors::ParseError::unexpected_eof(delimiter.to_string(), span),
|
||||
partial: Some(bare.spanned(span)),
|
||||
|
@ -1358,7 +1358,7 @@ fn classify_pipeline(
|
||||
}),
|
||||
positional: Some(args),
|
||||
named: None,
|
||||
span: Span::unknown(),
|
||||
span: name_span,
|
||||
external_redirection: if iter.peek().is_none() {
|
||||
ExternalRedirection::None
|
||||
} else {
|
||||
@ -1448,7 +1448,7 @@ fn classify_pipeline(
|
||||
}),
|
||||
positional: Some(args),
|
||||
named: None,
|
||||
span: Span::unknown(),
|
||||
span: name_span,
|
||||
external_redirection: if iter.peek().is_none() {
|
||||
ExternalRedirection::None
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user