@@ -250,7 +250,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
250
250
io:: stderr( ) . write_str( out) ;
251
251
}
252
252
253
-
253
+ // FIXME (#3260)
254
254
// If there's one line at fault we can easily point to the problem
255
255
if vec:: len( lines. lines) == 1 u {
256
256
let lo = cm. lookup_char_pos( sp. lo) ;
@@ -263,14 +263,26 @@ fn highlight_lines(cm: @codemap::CodeMap,
263
263
// indent past |name:## | and the 0-offset column location
264
264
let mut left = str:: len( fm. name) + digits + lo. col. to_uint( ) + 3 u;
265
265
let mut s = ~"";
266
- while left > 0 u { str : : push_char( & mut s, ' ' ) ; left -= 1 u; }
267
-
266
+ // Skip is the number of characters we need to skip because they are
267
+ // part of the 'filename:line ' part of the previous line.
268
+ let skip = str:: len( fm. name) + digits + 3 u;
269
+ for skip. times( ) {
270
+ s += ~" ";
271
+ }
272
+ let orig = fm.get_line(lines.lines[0] as int);
273
+ for uint::range(0u,left-skip) |pos| {
274
+ let curChar = (orig[pos] as char);
275
+ s += match curChar { // Whenever a tab occurs on the previous
276
+ '\t ' => "\t " , // line, we insert one on the error-point-
277
+ _ => " " // -squigly-line as well (instead of a
278
+ }; // space). This way the squigly-line will
279
+ } // usually appear in the correct position.
268
280
s += ~" ^";
269
281
let hi = cm. lookup_char_pos( sp. hi) ;
270
282
if hi. col != lo. col {
271
283
// the ^ already takes up one space
272
- let mut width = hi. col. to_uint( ) - lo. col. to_uint( ) - 1 u;
273
- while width > 0 u { str : : push_char ( & mut s , '~' ) ; width -= 1 u ; }
284
+ let num_squiglies = hi. col. to_uint( ) - lo. col. to_uint( ) - 1 u;
285
+ for num_squiglies . times ( ) { s += ~"~" ; }
274
286
}
275
287
io:: stderr( ) . write_str( s + ~"\n ") ;
276
288
}
0 commit comments