@@ -295,7 +295,11 @@ impl Printer {
295295 let mut counter = 1 ;
296296
297297 // split line
298- for l in text. split ( '\n' ) {
298+ for mut l in text. split ( '\n' ) {
299+ if l. is_empty ( ) {
300+ l = "\u{200B} " ;
301+ }
302+
299303 let mut line = vec ! [ ] ;
300304
301305 if self . is_line_number {
@@ -327,25 +331,46 @@ impl Printer {
327331 /// generate output at DiffMOde::Watch
328332 fn gen_watch_diff_output < ' a > ( & mut self , dest : & str , src : & str ) -> PrintData < ' a > {
329333 // tab expand dest
330- let mut text_dest = dest. to_string ( ) ;
334+ let mut text_dest_str = dest. to_string ( ) ;
331335 if !self . is_batch {
332- text_dest = expand_line_tab ( dest, self . tab_size ) ;
336+ text_dest_str = expand_line_tab ( dest, self . tab_size ) ;
333337
334338 if !self . is_color {
335- text_dest = ansi:: escape_ansi ( & text_dest) ;
339+ text_dest_str = ansi:: escape_ansi ( & text_dest_str) ;
340+ }
341+ }
342+
343+ let mut text_dest: String = "" . to_string ( ) ;
344+ for mut l in text_dest_str. lines ( ) {
345+ if l. is_empty ( ) {
346+ l = "\u{200B} " ;
336347 }
348+
349+ text_dest. push_str ( l) ;
350+ text_dest. push_str ( "\n " ) ;
337351 }
338352
339353 // tab expand src
340- let mut text_src = src. to_string ( ) ;
354+ let mut text_src_str = src. to_string ( ) ;
341355 if !self . is_batch {
342- text_src = expand_line_tab ( src, self . tab_size ) ;
356+ text_src_str = expand_line_tab ( src, self . tab_size ) ;
343357
344358 if !self . is_color {
345- text_src = ansi:: escape_ansi ( & text_src ) ;
359+ text_src_str = ansi:: escape_ansi ( & text_src_str ) ;
346360 }
347361 }
348362
363+ let mut text_src: String = "" . to_string ( ) ;
364+ for mut l in text_src_str. lines ( ) {
365+ if l. is_empty ( ) {
366+ l = "\u{200B} " ;
367+ }
368+
369+ text_src. push_str ( l) ;
370+ text_src. push_str ( "\n " ) ;
371+ }
372+
373+
349374 // create text vector
350375 let mut vec_src: Vec < & str > = text_src. lines ( ) . collect ( ) ;
351376 let mut vec_dest: Vec < & str > = text_dest. lines ( ) . collect ( ) ;
0 commit comments