Skip to content

Commit

Permalink
Column numbers should start at 1.
Browse files Browse the repository at this point in the history
ripgrep was documented to do 1-based indexing, so this is a bug and not
a breaking change.

Fixes BurntSushi#18
  • Loading branch information
amsharma91 committed Sep 20, 2016
1 parent dab3e8c commit 1a42011
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<W: Terminal + Send> Printer<W> {
self.line_number(line_number, b':');
}
if let Some(c) = column {
self.write(c.to_string().as_bytes());
self.write((c + 1).to_string().as_bytes());
self.write(b":");
}
if self.replace.is_some() {
Expand Down
12 changes: 6 additions & 6 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ sherlock!(columns, |wd: WorkDir, mut cmd: Command| {
cmd.arg("--column");
let lines: String = wd.stdout(&mut cmd);
let expected = "\
57:For the Doctor Watsons of this world, as opposed to the Sherlock
49:be, to a very large extent, the result of luck. Sherlock Holmes
58:For the Doctor Watsons of this world, as opposed to the Sherlock
50:be, to a very large extent, the result of luck. Sherlock Holmes
";
assert_eq!(lines, expected);
});
Expand Down Expand Up @@ -574,10 +574,10 @@ sherlock!(vimgrep, "Sherlock|Watson", ".", |wd: WorkDir, mut cmd: Command| {

let lines: String = wd.stdout(&mut cmd);
let expected = "\
sherlock:1:15:For the Doctor Watsons of this world, as opposed to the Sherlock
sherlock:1:56:For the Doctor Watsons of this world, as opposed to the Sherlock
sherlock:3:48:be, to a very large extent, the result of luck. Sherlock Holmes
sherlock:5:11:but Doctor Watson has to have it taken out for him and dusted,
sherlock:1:16:For the Doctor Watsons of this world, as opposed to the Sherlock
sherlock:1:57:For the Doctor Watsons of this world, as opposed to the Sherlock
sherlock:3:49:be, to a very large extent, the result of luck. Sherlock Holmes
sherlock:5:12:but Doctor Watson has to have it taken out for him and dusted,
";
assert_eq!(lines, expected);
});
Expand Down

0 comments on commit 1a42011

Please sign in to comment.