From 078f91b162d099634700478eb08c9eab85a03ba2 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 2 Oct 2018 22:12:41 +0200 Subject: [PATCH] Fix tests and clippy warnings --- src/grid/tests.rs | 8 ++++---- src/input.rs | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/grid/tests.rs b/src/grid/tests.rs index e136e3b3..78728464 100644 --- a/src/grid/tests.rs +++ b/src/grid/tests.rs @@ -14,7 +14,7 @@ //! Tests for the Gird -use super::{Grid, BidirectionalIterator}; +use super::{Grid}; use index::{Point, Line, Column}; // Scroll up moves lines upwards @@ -112,7 +112,7 @@ fn test_iter() { col: Column(0), }); - assert_eq!(None, iter.prev()); + assert_eq!(None, iter.next_back()); assert_eq!(Some(&1), iter.next()); assert_eq!(Column(1), iter.cur.col); assert_eq!(4, iter.cur.line); @@ -126,7 +126,7 @@ fn test_iter() { assert_eq!(Column(0), iter.cur.col); assert_eq!(3, iter.cur.line); - assert_eq!(Some(&4), iter.prev()); + assert_eq!(Some(&4), iter.next_back()); assert_eq!(Column(4), iter.cur.col); assert_eq!(4, iter.cur.line); @@ -137,5 +137,5 @@ fn test_iter() { col: Column(4), }); assert_eq!(None, final_iter.next()); - assert_eq!(Some(&23), final_iter.prev()); + assert_eq!(Some(&23), final_iter.next_back()); } diff --git a/src/input.rs b/src/input.rs index 28681341..4fabad73 100644 --- a/src/input.rs +++ b/src/input.rs @@ -488,20 +488,18 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { } else { // Spawn URL launcher when clicking on URLs let moved = self.ctx.mouse().last_press_pos != (self.ctx.mouse().x, self.ctx.mouse().y); - let ref url_launcher = self.mouse_config.url_launcher; - match (self.ctx.mouse_coords(), url_launcher, moved) { - (Some(point), Some(launcher), false) => { - if let Some(text) = self.ctx.url(Point::new(point.line.0, point.col)) { - let mut args = launcher.args().to_vec(); - args.push(text); - debug!("Launching: {} {:?}", launcher.program(), args); - Command::new(launcher.program()) - .args(&args) - .spawn() - .expect("url launcher error"); - } + if let (Some(point), Some(launcher), false) = + (self.ctx.mouse_coords(), &self.mouse_config.url_launcher, moved) + { + if let Some(text) = self.ctx.url(Point::new(point.line.0, point.col)) { + let mut args = launcher.args().to_vec(); + args.push(text); + debug!("Launching: {} {:?}", launcher.program(), args); + Command::new(launcher.program()) + .args(&args) + .spawn() + .expect("url launcher error"); } - _ => (), } } @@ -798,6 +796,10 @@ mod tests { self.mouse } + fn url(&self, _: Point) -> Option { + None + } + fn received_count(&mut self) -> &mut usize { &mut self.received_count } @@ -866,11 +868,12 @@ mod tests { threshold: Duration::from_millis(1000), }, faux_scrollback_lines: None, + url_launcher: None, }, scrolling_config: &config::Scrolling::default(), key_bindings: &config.key_bindings()[..], mouse_bindings: &config.mouse_bindings()[..], - save_to_clipboard: config.selection().save_to_clipboard + save_to_clipboard: config.selection().save_to_clipboard, }; if let Event::WindowEvent { event: WindowEvent::MouseInput { state, button, modifiers, .. }, .. } = $input {