Add configuration option to disable hinter (#2403) (#2405)

* Add configuration option to disable hinter

* Move hint configuration inside line_editor
This commit is contained in:
Amit Dev
2020-08-27 15:45:55 +10:00
committed by GitHub
parent 7702d683c7
commit 39f402c8cc
2 changed files with 19 additions and 5 deletions

View File

@ -12,16 +12,16 @@ use crate::shell::palette::{DefaultPalette, Palette};
pub struct Helper {
completer: NuCompleter,
hinter: rustyline::hint::HistoryHinter,
hinter: Option<rustyline::hint::HistoryHinter>,
context: Context,
pub colored_prompt: String,
}
impl Helper {
pub(crate) fn new(context: Context) -> Helper {
pub(crate) fn new(context: Context, hinter: Option<rustyline::hint::HistoryHinter>) -> Helper {
Helper {
completer: NuCompleter {},
hinter: rustyline::hint::HistoryHinter {},
hinter,
context,
colored_prompt: String::new(),
}
@ -54,7 +54,7 @@ impl rustyline::completion::Completer for Helper {
impl rustyline::hint::Hinter for Helper {
fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option<String> {
self.hinter.hint(line, pos, &ctx)
self.hinter.as_ref().and_then(|h| h.hint(line, pos, &ctx))
}
}