Skip to content

Commit 5fa21af

Browse files
committed
#3 Add M regex flag for colored diff
1 parent bf2412b commit 5fa21af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

diffplus/incremental_diff.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .indented_config import IndentedConfig
2-
from re import sub
2+
from re import sub, M
33

44
class IncrementalDiff:
55
#
@@ -34,7 +34,7 @@ def to_dict(self):
3434
def __str__(self):
3535
str_ = IncrementalDiff._to_str(self.to_dict(), indent_char=self.a.indent_char)
3636
if self.colored:
37-
str_ = sub('(\+.*)', fr'{self._COLOR_GREEN}\1{self._COLOR_RESET}', str_)
37+
str_ = sub('^(\+.*)$', fr'{self._COLOR_GREEN}\1{self._COLOR_RESET}', str_, flags=M)
3838
return str_.rstrip('\n') # just a little hack to remove the last newline char
3939

4040
#

0 commit comments

Comments
 (0)