File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ pub use self::object::{
202202use std:: fmt:: { self , Debug , Formatter } ;
203203use std:: io:: Write ;
204204use std:: ops:: { Deref , DerefMut } ;
205+
205206use crate :: chunk:: WriteSettings ;
206207
207208use self :: writers:: * ;
You can’t perform that action at this time.
0 commit comments