Explorar el Código

Fix issue 44: unexpected side-by-side output for diff of diff

Common error of using lstrip:

 lstrip('\x00+') will eat all '+' after '\x00'
Matthew Wang hace 9 años
padre
commit
10fa1e838a
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6
    2
      cdiff.py

+ 6
- 2
cdiff.py Ver fichero

547
                 if changed:
547
                 if changed:
548
                     if not old[0]:
548
                     if not old[0]:
549
                         left = '%*s' % (width, ' ')
549
                         left = '%*s' % (width, ' ')
550
-                        right = right.lstrip('\x00+').rstrip('\x01')
550
+                        right = right.rstrip('\x01')
551
+                        if right.startswith('\x00+'):
552
+                            right = right[2:]
551
                         right = _fit_with_marker(
553
                         right = _fit_with_marker(
552
                             right, self._markup_new, width)
554
                             right, self._markup_new, width)
553
                     elif not new[0]:
555
                     elif not new[0]:
554
-                        left = left.lstrip('\x00-').rstrip('\x01')
556
+                        left = left.rstrip('\x01')
557
+                        if left.startswith('\x00-'):
558
+                            left = left[2:]
555
                         left = _fit_with_marker(left, self._markup_old, width)
559
                         left = _fit_with_marker(left, self._markup_old, width)
556
                         right = ''
560
                         right = ''
557
                     else:
561
                     else: