Skip to content

Commit a5ac8f1

Browse files
jdmbrson
authored andcommitted
Use the actual start position of the file in the codemap rather than the position of the first newline.
1 parent 6359824 commit a5ac8f1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/comp/syntax/codemap.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color,
6363
alt (sp) {
6464
case (some(?ssp)) {
6565
ss = span_to_str(ssp, cm);
66-
6766
maybe_lines = some(span_to_lines(ssp, cm));
68-
6967
}
7068
case (none) { }
7169
}
@@ -170,12 +168,12 @@ fn span_to_lines(span sp, codemap::codemap cm) -> @file_lines {
170168
}
171169

172170
fn get_line(filemap fm, int line, &str file) -> str {
173-
let uint begin = fm.lines.(line) - fm.lines.(0);
171+
let uint begin = fm.lines.(line) - fm.start_pos;
174172
let uint end;
175173
if ((line as uint) + 1u >= ivec::len(fm.lines)) {
176174
end = str::byte_len(file);
177175
} else {
178-
end = fm.lines.(line + 1) - fm.lines.(0);
176+
end = fm.lines.(line + 1) - fm.start_pos;
179177
}
180178
ret str::slice(file, begin, end);
181179
}

0 commit comments

Comments
 (0)