Translated absolute byte offset to relative
This commit is contained in:
parent
c67ae04aca
commit
3d49cc1198
1 changed files with 9 additions and 1 deletions
|
@ -635,7 +635,15 @@ impl server::Span for Rustc<'_, '_> {
|
|||
}
|
||||
|
||||
fn byte_range(&mut self, span: Self::Span) -> Range<usize> {
|
||||
Range { start: span.lo().0 as usize, end: span.hi().0 as usize }
|
||||
let source_map = self.sess().source_map();
|
||||
|
||||
let relative_start_pos = source_map.lookup_byte_offset(span.lo()).pos;
|
||||
let relative_end_pos = source_map.lookup_byte_offset(span.hi()).pos;
|
||||
|
||||
Range {
|
||||
start: relative_start_pos.0 as usize,
|
||||
end: relative_end_pos.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
fn start(&mut self, span: Self::Span) -> LineColumn {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue