mirror of
https://github.com/python/cpython.git
synced 2025-07-29 22:24:49 +00:00
Fix for issue1488943 - difflib.Differ() doesn't always add hints for tab
characters.
This commit is contained in:
parent
f058d2dc08
commit
5c456e6f45
3 changed files with 15 additions and 4 deletions
|
@ -1061,20 +1061,21 @@ class Differ:
|
|||
Example:
|
||||
|
||||
>>> d = Differ()
|
||||
>>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
|
||||
... ' ^ ^ ^ ', '+ ^ ^ ^ ')
|
||||
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
|
||||
... ' ^ ^ ^ ', ' ^ ^ ^ ')
|
||||
>>> for line in results: print repr(line)
|
||||
...
|
||||
'- \tabcDefghiJkl\n'
|
||||
'? \t ^ ^ ^\n'
|
||||
'+ \t\tabcdefGhijkl\n'
|
||||
'? \t ^ ^ ^\n'
|
||||
'+ \tabcdefGhijkl\n'
|
||||
'? \t ^ ^ ^\n'
|
||||
"""
|
||||
|
||||
# Can hurt, but will probably help most of the time.
|
||||
common = min(_count_leading(aline, "\t"),
|
||||
_count_leading(bline, "\t"))
|
||||
common = min(common, _count_leading(atags[:common], " "))
|
||||
common = min(common, _count_leading(btags[:common], " "))
|
||||
atags = atags[common:].rstrip()
|
||||
btags = btags[common:].rstrip()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue