mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 05:24:56 +02:00
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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user