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:
Jason Gedge
2020-08-21 15:37:51 -04:00
committed by GitHub
parent 0dd1403a69
commit 9f85b10fcb
14 changed files with 589 additions and 381 deletions

View File

@ -7,7 +7,6 @@ use crate::context::Context;
use crate::git::current_branch;
use crate::path::canonicalize;
use crate::prelude::*;
use crate::shell::completer::NuCompleter;
use crate::shell::Helper;
use crate::EnvironmentSyncer;
use futures_codec::FramedRead;
@ -787,10 +786,7 @@ pub async fn cli(
let cwd = context.shell_manager.path();
rl.set_helper(Some(crate::shell::Helper::new(
Box::new(<NuCompleter as Default>::default()),
context.clone(),
)));
rl.set_helper(Some(crate::shell::Helper::new(context.clone())));
let colored_prompt = {
if let Some(prompt) = config.get("prompt") {