Skip to content

Commit 9f24a24

Browse files
bors[bot]CAD97
andauthored
Merge #32
32: Report 1-based indices in Error's Display impl r=lnicola a=CAD97 This matches every (mainstream) text editor's use of the line:column format. I actually lost some time trying to figure out why it was complaining about an empty line before I realized why 😅 I kept `Location` 0-based and translated just at the point of display, as that was a much less invasive change. Co-authored-by: Christopher Durham <cad97@cad97.com>
2 parents 222f4d2 + 0f5b22f commit 9f24a24

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub struct Error {
1616
impl fmt::Display for Error {
1717
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1818
if let Some(loc) = self.location {
19-
write!(f, "{}:{}: ", loc.line, loc.column)?
19+
// Report 1-based indices, to match text editors
20+
write!(f, "{}:{}: ", loc.line + 1, loc.column + 1)?
2021
}
2122
write!(f, "{}", self.message)
2223
}

0 commit comments

Comments
 (0)