Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stringtables: add trailing newline, trim for comparisions #826

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(())
}
}
Loading