Skip to content

Commit

Permalink
stringtables: add trailing newline, trim for comparisions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Nov 9, 2024
1 parent ab357f8 commit e2bd90b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/stringtable/src/analyze/lints/01_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl LintRunner<SqfLintData> for Runner {
if let Err(e) = project.to_writer(&mut writer) {
panic!("Failed to write stringtable for {path}: {e}");
}
if &writer != existing {
if writer.trim() != existing.trim() {
unsorted.push(path.as_str().to_string());
}
}
Expand Down
8 changes: 6 additions & 2 deletions libs/stringtable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ impl Project {
// If this write fails, the serializer will also throw an error
let _ = writer.write_str(r#"<?xml version="1.0" encoding="utf-8"?>"#);
let _ = writer.write_char('\n');
let mut ser = Serializer::new(writer);
let mut buffer = String::new();
let mut ser = Serializer::new(&mut buffer);
ser.indent(' ', 4);
self.serialize(ser)
self.serialize(ser)?;
buffer.push('\n');
writer.write_str(&buffer)?;
Ok(())
}
}

0 comments on commit e2bd90b

Please sign in to comment.