mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 00:52:27 +02:00
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:
@ -526,10 +526,11 @@ impl Span {
|
||||
/// let span = Span::new(2, 8);
|
||||
///
|
||||
/// assert_eq!(span.contains(5), true);
|
||||
/// assert_eq!(span.contains(8), false);
|
||||
/// assert_eq!(span.contains(100), false);
|
||||
/// ```
|
||||
pub fn contains(&self, pos: usize) -> bool {
|
||||
self.start <= pos && self.end >= pos
|
||||
self.start <= pos && pos < self.end
|
||||
}
|
||||
|
||||
/// Returns a new Span by merging an earlier Span with the current Span.
|
||||
|
Reference in New Issue
Block a user