From 187c77679851292e1d8cc199a440d10f164ab185 Mon Sep 17 00:00:00 2001 From: Haitao Li Date: Thu, 24 Nov 2011 14:58:38 +0800 Subject: [PATCH] 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. --- src/comp/syntax/codemap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index cd48deba5113..106a4dae46a4 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -193,7 +193,7 @@ fn maybe_highlight_lines(sp: option::t, cm: codemap, if vec::len(lines.lines) == 1u { let lo = lookup_char_pos(cm, option::get(sp).lo); let digits = 0u; - let num = lines.lines[0] / 10u; + let num = (lines.lines[0] + 1u) / 10u; // how many digits must be indent past? while num > 0u { num /= 10u; digits += 1u; }