Skip to content

Commit 0f5b22f

Browse files
authored
Report 1-based indices in Error's Display impl
This matches every (mainstream) text editor's use of the line:column format.
1 parent 222f4d2 commit 0f5b22f

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)