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:
parent
ba30c1dac9
commit
a1f8a6ce80
2 changed files with 7 additions and 7 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue