diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 6789045f1..21d56ad0d 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -37,6 +37,7 @@ from beets.util.functemplate import Template from beets import config from beets.util import confit from beets.autotag import mb +from beets.autotag.match import string_dist # On Windows platforms, use colorama to support "ANSI" terminal colors. @@ -366,7 +367,7 @@ def colorize(color, text): else: return text -def _colordiff(a, b, highlight='red'): +def _colordiff(a, b, highlight='red', second_highlight='lightgray'): """Given two values, return the same pair of strings except with their differences highlighted in the specified color. Strings are highlighted intelligently to show differences; other values are @@ -402,9 +403,14 @@ def _colordiff(a, b, highlight='red'): # Left only. a_out.append(colorize(highlight, a[a_start:a_end])) elif op == 'replace': - # Right and left differ. - a_out.append(colorize(highlight, a[a_start:a_end])) - b_out.append(colorize(highlight, b[b_start:b_end])) + # Right and left differ. Colorise with second highlight if + # there's no distance penalty. + if string_dist(a[a_start:a_end], b[b_start:b_end]): + color = highlight + else: + color = second_highlight + a_out.append(colorize(color, a[a_start:a_end])) + b_out.append(colorize(color, b[b_start:b_end])) else: assert(False) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9d9cb8403..1daa09ef3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -62,7 +62,9 @@ Changelog low similarity score. * Display album disambiguation and disc titles in the track listing, when available. - * More consistent format and colorization of album and track metadata. + * More consistent format and colorization of album and track metadata. Red + for actual differences, yellow to indicate that a penalty is being applied, + and light gray for no-penalty supplementary data. * Track changes highlighted in light gray indicate a change in format to or from :ref:`per_disc_numbering`. No penalty is applied because the track number is still "correct", just in a different format.