fix: quote file names that contain spaces when printing them to stdout (#51)

This commit is contained in:
Fred Morcos 2024-11-21 00:29:49 +01:00 committed by GitHub
parent d3564f2aca
commit 21cdaaee42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,6 +105,10 @@ impl Entry {
pub fn stdout_repr(&self) -> String { pub fn stdout_repr(&self) -> String {
let mut repr = self.name.clone(); let mut repr = self.name.clone();
if repr.contains(|c| char::is_ascii_whitespace(&c)) {
repr.insert(0, '\'');
repr.push('\'');
}
if let Some(line_number) = self.line_number { if let Some(line_number) = self.line_number {
repr.push_str(&format!(":{line_number}")); repr.push_str(&format!(":{line_number}"));
} }