mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Trim end and add empty line for POSIX
This commit is contained in:
parent
cad02d878c
commit
813845e7d1
2 changed files with 9 additions and 0 deletions
|
@ -180,6 +180,9 @@ fn fmt_all<'a>(arena: &'a Bump, buf: &mut Buf<'a>, ast: &'a Ast) {
|
|||
for def in &ast.defs {
|
||||
fmt_def(buf, arena.alloc(def.value), 0);
|
||||
}
|
||||
|
||||
buf.trim_end();
|
||||
buf.newline();
|
||||
}
|
||||
|
||||
/// RemoveSpaces normalizes the ast to something that we _expect_ to be invariant under formatting.
|
||||
|
|
|
@ -90,4 +90,10 @@ impl<'a> Buf<'a> {
|
|||
self.spaces_to_flush = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trim_end(&mut self) {
|
||||
while self.text.ends_with(char::is_whitespace) {
|
||||
self.text.truncate(self.text.len() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue