From 36e9e53b37c4983da4ba7a8c30e13cfe27f42855 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 9 Feb 2021 00:25:10 +0800 Subject: refactor(cli/tools/repl): merge highlighter into helper (#9448) --- cli/tools/repl.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'cli') diff --git a/cli/tools/repl.rs b/cli/tools/repl.rs index 8e3df4109..73d1688e5 100644 --- a/cli/tools/repl.rs +++ b/cli/tools/repl.rs @@ -37,7 +37,6 @@ struct Helper { context_id: u64, message_tx: SyncSender<(String, Option)>, response_rx: Receiver>, - highlighter: LineHighlighter, } impl Helper { @@ -183,32 +182,18 @@ impl Highlighter for Helper { hint.into() } - fn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str> { - self.highlighter.highlight(line, pos) - } - fn highlight_candidate<'c>( &self, candidate: &'c str, _completion: rustyline::CompletionType, ) -> Cow<'c, str> { - self.highlighter.highlight(candidate, 0) + self.highlight(candidate, 0) } fn highlight_char(&self, line: &str, _: usize) -> bool { !line.is_empty() } -} - -struct LineHighlighter; - -impl LineHighlighter { - fn new() -> Self { - Self - } -} -impl Highlighter for LineHighlighter { fn highlight<'l>(&self, line: &'l str, _: usize) -> Cow<'l, str> { let mut out_line = String::from(line); @@ -436,7 +421,6 @@ pub async fn run( context_id, message_tx, response_rx, - highlighter: LineHighlighter::new(), }; let editor = Arc::new(Mutex::new(Editor::new())); -- cgit v1.2.3