1
Fork 0

Fix FileMap::line_begin_pos().

The method relied on the FileMap still being under construction in
order for it to do what the name promises. It's now independent of
the current state.
This commit is contained in:
Michael Woerister 2018-06-28 10:45:57 +02:00
parent ba30c1dac9
commit a1f8a6ce80
2 changed files with 7 additions and 7 deletions

View file

@ -976,11 +976,9 @@ impl FileMap {
}
/// Return the BytePos of the beginning of the current line.
pub fn line_begin_pos(&self) -> BytePos {
match self.lines.last() {
Some(&line_pos) => line_pos,
None => self.start_pos,
}
pub fn line_begin_pos(&self, pos: BytePos) -> BytePos {
let line_index = self.lookup_line(pos).unwrap();
self.lines[line_index]
}
/// Add externally loaded source.