fixed show_hints option to allow hints to be turned off (#3780)

This commit is contained in:
Darren Schroeder 2021-07-14 09:47:33 -05:00 committed by GitHub
parent 37612345f2
commit 2864eaebae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -247,7 +247,7 @@ pub fn rustyline_hinter(
) -> Option<rustyline::hint::HistoryHinter> {
if let Some(line_editor_vars) = config.var("line_editor") {
for (idx, value) in line_editor_vars.row_entries() {
if idx == "show_hints" && value.expect_string() == "false" {
if idx == "show_hints" && value.as_bool() == Ok(false) {
return None;
}
}

View file

@ -90,7 +90,10 @@ impl rustyline::completion::Completer for Helper {
impl rustyline::hint::Hinter for Helper {
type Hint = String;
fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option<String> {
self.hinter.as_ref().and_then(|h| h.hint(line, pos, ctx))
match &self.hinter {
Some(the_hinter) => the_hinter.hint(line, pos, ctx),
None => Some("".to_string()),
}
}
}