Skip to content

Commit 2253ed5

Browse files
lhtmarijnh
authored andcommitted
rustc: Fix position of diagnostic highlight lines
Diagnostic highlight lines are incorrect placed when the related line number is 10, 100, etc. The root cause is line number are treated as 0 based (should be 1 based) when calculating offset of line number digits.
1 parent 8746ebe commit 2253ed5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/comp/syntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn maybe_highlight_lines(sp: option::t<span>, cm: codemap,
193193
if vec::len(lines.lines) == 1u {
194194
let lo = lookup_char_pos(cm, option::get(sp).lo);
195195
let digits = 0u;
196-
let num = lines.lines[0] / 10u;
196+
let num = (lines.lines[0] + 1u) / 10u;
197197

198198
// how many digits must be indent past?
199199
while num > 0u { num /= 10u; digits += 1u; }

0 commit comments

Comments
 (0)