diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-09 00:25:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 17:25:10 +0100 |
commit | 36e9e53b37c4983da4ba7a8c30e13cfe27f42855 (patch) | |
tree | aa3543ef400e19f1f275d69877917a06dc871954 /cli/tools/repl.rs | |
parent | 1f9e9002d527022130e4deba0b34b1ba466216d8 (diff) |
refactor(cli/tools/repl): merge highlighter into helper (#9448)
Diffstat (limited to 'cli/tools/repl.rs')
-rw-r--r-- | cli/tools/repl.rs | 18 |
1 files changed, 1 insertions, 17 deletions
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<Value>)>, response_rx: Receiver<Result<Value, AnyError>>, - 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())); |