Skip to content

Commit e4b2f58

Browse files
authored
fix: Do not set source_contents if it already exists (#68)
1 parent 7a842b0 commit e4b2f58

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/types.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,12 @@ impl SourceMap {
951951
let name = original.get_name(token.name_id);
952952
let source = original.get_source(token.src_id);
953953

954-
if let Some(source) = source {
955-
let contents = original.get_source_contents(token.src_id);
956-
957-
let new_id = builder.add_source(source);
958-
builder.set_source_contents(new_id, contents);
954+
if !builder.has_source_contents(token.src_id) {
955+
if let Some(source) = source {
956+
let contents = original.get_source_contents(token.src_id);
957+
let new_id = builder.add_source(source);
958+
builder.set_source_contents(new_id, contents);
959+
}
959960
}
960961

961962
let dst_line = (token.dst_line as i32 + line_diff) as u32;

0 commit comments

Comments
 (0)