From e330fdabb735a78d5f05f7b864b9053d57b2245c Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 15 Oct 2021 15:42:36 -0500 Subject: [PATCH] updated theme + clippy --- src/main.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1496152866..dc3aa39507 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,10 @@ use std::{cell::RefCell, io::Write, rc::Rc}; -use dialoguer::{console::Term, theme::ColorfulTheme, Select}; +use dialoguer::{ + console::{Style, Term}, + theme::ColorfulTheme, + Select, +}; use miette::{IntoDiagnostic, Result}; use nu_cli::{report_error, NuCompleter, NuHighlighter, NuValidator, NushellPrompt}; use nu_command::create_default_context; @@ -45,25 +49,24 @@ impl CompletionActionHandler for FuzzyCompletion { let _ = crossterm::terminal::disable_raw_mode(); println!(); - let result = Select::with_theme(&ColorfulTheme::default()) + let mut theme = ColorfulTheme::default(); + theme.active_item_style = Style::new().for_stderr().on_green().black(); + let result = Select::with_theme(&theme) .default(0) .items(&selections[..]) .interact_on_opt(&Term::stdout()) .unwrap(); let _ = crossterm::terminal::enable_raw_mode(); - match result { - Some(result) => { - let span = completions[result].0; + if let Some(result) = result { + let span = completions[result].0; - let mut offset = present_buffer.offset(); - offset += completions[result].1.len() - (span.end - span.start); + let mut offset = present_buffer.offset(); + offset += completions[result].1.len() - (span.end - span.start); - // TODO improve the support for multiline replace - present_buffer.replace(span.start..span.end, &completions[result].1); - present_buffer.set_insertion_point(offset); - } - None => {} + // TODO improve the support for multiline replace + present_buffer.replace(span.start..span.end, &completions[result].1); + present_buffer.set_insertion_point(offset); } } }