equal
deleted
inserted
replaced
2729 |
2729 |
2730 |
2730 |
2731 def diffsinglehunkinline(hunklines): |
2731 def diffsinglehunkinline(hunklines): |
2732 """yield tokens for a list of lines in a single hunk, with inline colors""" |
2732 """yield tokens for a list of lines in a single hunk, with inline colors""" |
2733 # prepare deleted, and inserted content |
2733 # prepare deleted, and inserted content |
2734 a = b'' |
2734 a = bytearray() |
2735 b = b'' |
2735 b = bytearray() |
2736 for line in hunklines: |
2736 for line in hunklines: |
2737 if line[0:1] == b'-': |
2737 if line[0:1] == b'-': |
2738 a += line[1:] |
2738 a += line[1:] |
2739 elif line[0:1] == b'+': |
2739 elif line[0:1] == b'+': |
2740 b += line[1:] |
2740 b += line[1:] |
2744 if not a or not b: |
2744 if not a or not b: |
2745 for t in diffsinglehunk(hunklines): |
2745 for t in diffsinglehunk(hunklines): |
2746 yield t |
2746 yield t |
2747 return |
2747 return |
2748 # re-split the content into words |
2748 # re-split the content into words |
2749 al = wordsplitter.findall(a) |
2749 al = wordsplitter.findall(bytes(a)) |
2750 bl = wordsplitter.findall(b) |
2750 bl = wordsplitter.findall(bytes(b)) |
2751 # re-arrange the words to lines since the diff algorithm is line-based |
2751 # re-arrange the words to lines since the diff algorithm is line-based |
2752 aln = [s if s == b'\n' else s + b'\n' for s in al] |
2752 aln = [s if s == b'\n' else s + b'\n' for s in al] |
2753 bln = [s if s == b'\n' else s + b'\n' for s in bl] |
2753 bln = [s if s == b'\n' else s + b'\n' for s in bl] |
2754 an = b''.join(aln) |
2754 an = b''.join(aln) |
2755 bn = b''.join(bln) |
2755 bn = b''.join(bln) |