Skip to content

Commit ef4e868

Browse files
committed
Fix tests
1 parent c67837b commit ef4e868

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/content.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ impl<'a> Operation<'a> {
109109
// is enabled, and only lazily add padding depending on whether it's really necessary
110110
// if not.
111111
let needs_padding = if self.write_settings.pretty {
112-
self.buf.push(pad_byte);
112+
if !self.buf.is_empty() {
113+
self.buf.push(pad_byte);
114+
}
115+
113116
false
114117
} else {
115118
true
@@ -127,8 +130,9 @@ impl Drop for Operation<'_> {
127130

128131
// For example, in case we previously wrote a BT operator and then a [] operand in the
129132
// next operation, we don't need to pad them.
130-
if self.write_settings.pretty
131-
|| self.buf.last().is_some_and(|b| !is_delimiter_character(*b))
133+
if (self.write_settings.pretty
134+
|| self.buf.last().is_some_and(|b| !is_delimiter_character(*b)))
135+
&& !self.buf.is_empty()
132136
{
133137
self.buf.push(pad_byte);
134138
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ pub use self::object::{
202202
use std::fmt::{self, Debug, Formatter};
203203
use std::io::Write;
204204
use std::ops::{Deref, DerefMut};
205+
205206
use crate::chunk::WriteSettings;
206207

207208
use self::writers::*;

0 commit comments

Comments
 (0)