Don't print extra newline in multiline | patterns

This commit is contained in:
Richard Feldman 2022-07-03 22:43:21 -04:00
parent d1ba89f97f
commit cab096b4e1
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
2 changed files with 9 additions and 1 deletions

View file

@ -89,6 +89,14 @@ impl<'a> Buf<'a> {
self.beginning_of_line = true;
}
/// Ensures the current buffer ends in a newline, if it didn't already.
/// Doesn't add a newline if the buffer already ends in one.
pub fn ensure_ends_in_newline(&mut self) {
if !self.text.ends_with('\n') {
self.newline()
}
}
fn flush_spaces(&mut self) {
if self.spaces_to_flush > 0 {
for _ in 0..self.spaces_to_flush {