mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
Use the actual start position of the file in the codemap rather than the position of the first newline.
This commit is contained in:
parent
63598248e4
commit
a5ac8f16db
@ -63,9 +63,7 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color,
|
|||||||
alt (sp) {
|
alt (sp) {
|
||||||
case (some(?ssp)) {
|
case (some(?ssp)) {
|
||||||
ss = span_to_str(ssp, cm);
|
ss = span_to_str(ssp, cm);
|
||||||
|
|
||||||
maybe_lines = some(span_to_lines(ssp, cm));
|
maybe_lines = some(span_to_lines(ssp, cm));
|
||||||
|
|
||||||
}
|
}
|
||||||
case (none) { }
|
case (none) { }
|
||||||
}
|
}
|
||||||
@ -170,12 +168,12 @@ fn span_to_lines(span sp, codemap::codemap cm) -> @file_lines {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_line(filemap fm, int line, &str file) -> str {
|
fn get_line(filemap fm, int line, &str file) -> str {
|
||||||
let uint begin = fm.lines.(line) - fm.lines.(0);
|
let uint begin = fm.lines.(line) - fm.start_pos;
|
||||||
let uint end;
|
let uint end;
|
||||||
if ((line as uint) + 1u >= ivec::len(fm.lines)) {
|
if ((line as uint) + 1u >= ivec::len(fm.lines)) {
|
||||||
end = str::byte_len(file);
|
end = str::byte_len(file);
|
||||||
} else {
|
} else {
|
||||||
end = fm.lines.(line + 1) - fm.lines.(0);
|
end = fm.lines.(line + 1) - fm.start_pos;
|
||||||
}
|
}
|
||||||
ret str::slice(file, begin, end);
|
ret str::slice(file, begin, end);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user