Skip to content

Commit 6e04a5c

Browse files
committed
return U diff for equal multiline strings when op_u enabled
1 parent 937e72b commit 6e04a5c

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

nested_diff/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def diff(self, differ, a, b):
711711
if diff:
712712
return equal, {'D': diff, 'E': self.extension_id}
713713

714-
return equal, {}
714+
return equal, {'U': a} if differ.op_u else {}
715715

716716
def patch(self, patcher, target, diff): # noqa U100
717717
"""Patch text (multiline string).

tests/data/formatters/HtmlFormatter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@
378378
'result': '<div class="nDvD"></div>',
379379
},
380380
'text_equal': {
381+
'result': '<div class="nDvD"><div> <div class="nDvU">&#x27;A\\nB\\nC&#x27;</div></div></div>',
382+
},
383+
'text_equal_noU': {
381384
'result': '<div class="nDvD"></div>',
382385
},
383386
'text_lcs': {

tests/data/formatters/TermFormatter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@
378378
'result': '',
379379
},
380380
'text_equal': {
381+
'result': " 'A\\nB\\nC'\x1b[0m\n",
382+
},
383+
'text_equal_noU': {
381384
'result': '',
382385
},
383386
'text_lcs': {

tests/data/formatters/TextFormatter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@
378378
'result': '',
379379
},
380380
'text_equal': {
381+
'result': " 'A\\nB\\nC'\n",
382+
},
383+
'text_equal_noU': {
381384
'result': '',
382385
},
383386
'text_lcs': {

tests/data/specific.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ def get_tests():
9696
'assert_func': lambda a, b: dumps(a) == dumps(b),
9797
},
9898
'text_equal': {
99+
'a': 'A\nB\nC',
100+
'b': 'A\nB\nC',
101+
'diff': {'U': 'A\nB\nC'},
102+
'handlers': {TextHandler: {'context': 3}},
103+
},
104+
'text_equal_noU': {
99105
'a': 'A\nB\nC',
100106
'b': 'A\nB\nC',
101107
'diff': {},

0 commit comments

Comments
 (0)