diff options
-rw-r--r-- | src/symbol_resolver.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/symbol_resolver.rs b/src/symbol_resolver.rs index c96ba67..ab4f8e1 100644 --- a/src/symbol_resolver.rs +++ b/src/symbol_resolver.rs @@ -251,6 +251,9 @@ impl SymbolResolver { fn push_source_code_to_string(string: &mut String, source_file: &SourceFile) { + // Don't push source code if it contains only whitespace. + let source_code = &source_file.symbols.source_code; + if source_code.chars().all(|c| c.is_whitespace()) { return; } // Ensure that sections are separated by two newlines. if !string.is_empty() { if !string.ends_with('\n') { string.push('\n'); } @@ -260,7 +263,7 @@ fn push_source_code_to_string(string: &mut String, source_file: &SourceFile) { let path_str = source_file.path.as_os_str().to_string_lossy(); let path_comment = format!("(: {path_str} )\n"); string.push_str(&path_comment); - string.push_str(&source_file.symbols.source_code); + string.push_str(&source_code); } |