From 00d12a1e6969f3f6c9307e4c216690ec6da339a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Thu, 10 Aug 2023 16:01:04 +0200 Subject: [PATCH] fix: Do not set source_contents if it already exists --- src/types.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/types.rs b/src/types.rs index 8d004172..41e8717c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -951,11 +951,12 @@ impl SourceMap { let name = original.get_name(token.name_id); let source = original.get_source(token.src_id); - if let Some(source) = source { - let contents = original.get_source_contents(token.src_id); - - let new_id = builder.add_source(source); - builder.set_source_contents(new_id, contents); + if !builder.has_source_contents(token.src_id) { + if let Some(source) = source { + let contents = original.get_source_contents(token.src_id); + let new_id = builder.add_source(source); + builder.set_source_contents(new_id, contents); + } } let dst_line = (token.dst_line as i32 + line_diff) as u32;