mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Context cleanup (#2581)
* Specialize 'Context' to EvaluationContext and CompletionContext * Specialize 'Context' to EvaluationContext and CompletionContext * fmt
This commit is contained in:
@ -4,7 +4,7 @@ use crate::completion::matchers;
|
||||
use crate::completion::matchers::Matcher;
|
||||
use crate::completion::path::{PathCompleter, PathSuggestion};
|
||||
use crate::completion::{self, Completer, Suggestion};
|
||||
use crate::context;
|
||||
use crate::evaluation_context::EvaluationContext;
|
||||
use nu_source::Tag;
|
||||
|
||||
use std::borrow::Cow;
|
||||
@ -18,11 +18,11 @@ impl NuCompleter {
|
||||
&self,
|
||||
line: &str,
|
||||
pos: usize,
|
||||
context: &completion::Context,
|
||||
context: &completion::CompletionContext,
|
||||
) -> (usize, Vec<Suggestion>) {
|
||||
use completion::engine::LocationType;
|
||||
|
||||
let nu_context: &context::Context = context.as_ref();
|
||||
let nu_context: &EvaluationContext = context.as_ref();
|
||||
let lite_block = match nu_parser::lite_parse(line, 0) {
|
||||
Ok(block) => Some(block),
|
||||
Err(result) => result.partial,
|
||||
|
@ -4,7 +4,7 @@ use nu_parser::SignatureRegistry;
|
||||
use nu_source::{Tag, Tagged};
|
||||
|
||||
use crate::completion;
|
||||
use crate::context::Context;
|
||||
use crate::evaluation_context::EvaluationContext;
|
||||
use crate::shell::completer::NuCompleter;
|
||||
use crate::shell::painter::Painter;
|
||||
use crate::shell::palette::DefaultPalette;
|
||||
@ -12,13 +12,16 @@ use crate::shell::palette::DefaultPalette;
|
||||
pub struct Helper {
|
||||
completer: NuCompleter,
|
||||
hinter: Option<rustyline::hint::HistoryHinter>,
|
||||
context: Context,
|
||||
context: EvaluationContext,
|
||||
pub colored_prompt: String,
|
||||
validator: NuValidator,
|
||||
}
|
||||
|
||||
impl Helper {
|
||||
pub(crate) fn new(context: Context, hinter: Option<rustyline::hint::HistoryHinter>) -> Helper {
|
||||
pub(crate) fn new(
|
||||
context: EvaluationContext,
|
||||
hinter: Option<rustyline::hint::HistoryHinter>,
|
||||
) -> Helper {
|
||||
Helper {
|
||||
completer: NuCompleter {},
|
||||
hinter,
|
||||
@ -48,7 +51,7 @@ impl rustyline::completion::Completer for Helper {
|
||||
pos: usize,
|
||||
_ctx: &rustyline::Context<'_>,
|
||||
) -> Result<(usize, Vec<Self::Candidate>), rustyline::error::ReadlineError> {
|
||||
let ctx = completion::Context::new(&self.context);
|
||||
let ctx = completion::CompletionContext::new(&self.context);
|
||||
Ok(self.completer.complete(line, pos, &ctx))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user