diff --git a/src/search_stream.rs b/src/search_stream.rs index b2b49d24..4e167121 100644 --- a/src/search_stream.rs +++ b/src/search_stream.rs @@ -327,16 +327,17 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> { #[inline(always)] fn fill(&mut self) -> Result { - let mut keep = self.inp.lastnl; - if self.opts.before_context > 0 || self.opts.after_context > 0 { + let keep = if self.opts.before_context > 0 || self.opts.after_context > 0 { let lines = 1 + cmp::max( self.opts.before_context, self.opts.after_context); - keep = start_of_previous_lines( + start_of_previous_lines( self.opts.eol, &self.inp.buf, self.inp.lastnl.saturating_sub(1), - lines); - } + lines) + } else { + self.inp.lastnl + }; if keep < self.last_printed { self.last_printed -= keep; } else { diff --git a/src/unescape.rs b/src/unescape.rs index 5d7a50e8..c27e6e28 100644 --- a/src/unescape.rs +++ b/src/unescape.rs @@ -14,8 +14,8 @@ enum State { /// Unescapes a string given on the command line. It supports a limited set of /// escape sequences: /// -/// * \t, \r and \n are mapped to their corresponding ASCII bytes. -/// * \xZZ hexadecimal escapes are mapped to their byte. +/// * `\t`, `\r` and `\n` are mapped to their corresponding ASCII bytes. +/// * `\xZZ` hexadecimal escapes are mapped to their byte. pub fn unescape(s: &str) -> Vec { use self::State::*; diff --git a/tests/tests.rs b/tests/tests.rs index 395514b2..0c5b4daf 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -62,7 +62,7 @@ fn paths(unix: &[&str]) -> Vec { fn paths_from_stdout(stdout: String) -> Vec { let mut paths: Vec<_> = stdout.lines().map(|s| { - s.split(":").next().unwrap().to_string() + s.split(':').next().unwrap().to_string() }).collect(); paths.sort(); paths diff --git a/tests/workdir.rs b/tests/workdir.rs index 1433f835..ea5408a4 100644 --- a/tests/workdir.rs +++ b/tests/workdir.rs @@ -13,7 +13,7 @@ use std::time::Duration; static TEST_DIR: &'static str = "ripgrep-tests"; static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT; -/// WorkDir represents a directory in which tests are run. +/// `WorkDir` represents a directory in which tests are run. /// /// Directories are created from a global atomic counter to avoid duplicates. #[derive(Debug)]