Fix wrong spans of multiple files

The introduction of `use <file.nu>` added the possibility of calling
`working_set.add_file()` more than once per parse pass. Some of the
logic handling the file contents offsets prevented it from working and
hopefully, this commit fixes it.
This commit is contained in:
Jakub Žádník
2021-10-31 17:22:10 +02:00
parent 2dcfecbbd7
commit 7112664b3f
2 changed files with 9 additions and 11 deletions

View File

@ -501,7 +501,7 @@ impl<'a> StateWorkingSet<'a> {
let permanent_span_start = self.permanent_state.next_span_start();
if let Some((_, _, last)) = self.delta.file_contents.last() {
permanent_span_start + *last
*last
} else {
permanent_span_start
}
@ -561,7 +561,7 @@ impl<'a> StateWorkingSet<'a> {
if permanent_end <= span.start {
for (contents, start, finish) in &self.delta.file_contents {
if (span.start >= *start) && (span.end <= *finish) {
return &contents[(span.start - permanent_end)..(span.end - permanent_end)];
return &contents[(span.start - start)..(span.end - start)];
}
}
} else {