mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 10:05:13 +01:00
Remove prefix diff highlighting
This was well-intentioned but ended up being more confusing than it was worth. It's always confused me when one digit gets un-highlighted in one of these displays. The straw that broke the camel's back was when I got a "#1 -> #16" change where the numeral "1" was un-highlighted. To fix this right would be way more trouble than it's worth; I'm glad to be rid of this detail. Conflicts: docs/changelog.rst
This commit is contained in:
parent
9b03c46702
commit
44ff3f782a
3 changed files with 9 additions and 41 deletions
|
|
@ -441,30 +441,6 @@ def colordiff(a, b, highlight='red'):
|
|||
return unicode(a), unicode(b)
|
||||
|
||||
|
||||
def color_diff_suffix(a, b, highlight='red'):
|
||||
"""Colorize the differing suffix between two strings."""
|
||||
a, b = unicode(a), unicode(b)
|
||||
if not config['color']:
|
||||
return a, b
|
||||
|
||||
# Fast path.
|
||||
if a == b:
|
||||
return a, b
|
||||
|
||||
# Find the longest common prefix.
|
||||
first_diff = None
|
||||
for i in range(min(len(a), len(b))):
|
||||
if a[i] != b[i]:
|
||||
first_diff = i
|
||||
break
|
||||
else:
|
||||
first_diff = min(len(a), len(b))
|
||||
|
||||
# Colorize from the first difference on.
|
||||
return (a[:first_diff] + colorize(highlight, a[first_diff:]),
|
||||
b[:first_diff] + colorize(highlight, b[first_diff:]))
|
||||
|
||||
|
||||
def get_path_formats(subview=None):
|
||||
"""Get the configuration's path formats as a list of query/template
|
||||
pairs.
|
||||
|
|
|
|||
|
|
@ -318,17 +318,9 @@ def show_change(cur_artist, cur_album, match):
|
|||
color = 'lightgray'
|
||||
else:
|
||||
color = 'red'
|
||||
if (cur_track + new_track).count('-') == 1:
|
||||
lhs_track, rhs_track = (ui.colorize(color, cur_track),
|
||||
ui.colorize(color, new_track))
|
||||
else:
|
||||
color = 'red'
|
||||
lhs_track, rhs_track = ui.color_diff_suffix(cur_track,
|
||||
new_track)
|
||||
templ = (ui.colorize(color, u' (#') + u'{0}' +
|
||||
ui.colorize(color, u')'))
|
||||
lhs += templ.format(lhs_track)
|
||||
rhs += templ.format(rhs_track)
|
||||
templ = ui.colorize(color, u' (#{0})')
|
||||
lhs += templ.format(cur_track)
|
||||
rhs += templ.format(new_track)
|
||||
lhs_width += len(cur_track) + 4
|
||||
|
||||
# Length change.
|
||||
|
|
@ -337,12 +329,9 @@ def show_change(cur_artist, cur_album, match):
|
|||
config['ui']['length_diff_thresh'].as_number():
|
||||
cur_length = ui.human_seconds_short(item.length)
|
||||
new_length = ui.human_seconds_short(track_info.length)
|
||||
lhs_length, rhs_length = ui.color_diff_suffix(cur_length,
|
||||
new_length)
|
||||
templ = (ui.colorize('red', u' (') + u'{0}' +
|
||||
ui.colorize('red', u')'))
|
||||
lhs += templ.format(lhs_length)
|
||||
rhs += templ.format(rhs_length)
|
||||
templ = ui.colorize('red', u' ({0})')
|
||||
lhs += templ.format(cur_length)
|
||||
rhs += templ.format(new_length)
|
||||
lhs_width += len(cur_length) + 3
|
||||
|
||||
# Penalties.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ Fixes:
|
|||
an argument.
|
||||
* :doc:`/plugins/play`: Remove the temporary .m3u file after sending it to
|
||||
the player.
|
||||
* The importer no longer tries to highlight partial differences in numeric
|
||||
quantities (track numbers and durations), which was often confusing.
|
||||
|
||||
|
||||
1.3.8 (September 17, 2014)
|
||||
--------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue