Commit 4afa1ccd authored by Ximin Luo's avatar Ximin Luo

difference: has_children -> has_visible_children, and take into account comments

An earlier commit made the [+]/[-] behaviour also show/hide comments so we
should add that logic to Difference as well. Also, we use the phrase "children"
elsewhere to refer to only the _details, so use a different phrase here.
parent f19e1ed1
......@@ -115,14 +115,14 @@ class Difference(object):
sum(map(len, self.comments)) +
sum(v.size() for v in self._visuals))
def has_children(self):
def has_visible_children(self):
Whether there are children.
Whether there are visible children.
Useful for e.g. choosing whether to display [+]/[-] controls.
return self._unified_diff is not None or self._details or self._visuals
return (self._unified_diff is not None or
self._comments or self._details or self._visuals)
def traverse_depth(self, depth=-1):
yield self
......@@ -337,7 +337,7 @@ class HTMLPresenter(Presenter):
print_func(u'<div class="difference">')
print_func(u'<div class="diffheader">')
diffcontrol = ("diffcontrol", u'⊟') if difference.has_children() else ("diffcontrol-nochildren", u'⊡')
diffcontrol = ("diffcontrol", u'⊟') if difference.has_visible_children() else ("diffcontrol-nochildren", u'⊡')
if difference.source1 == difference.source2:
print_func(u'<div class="%s">%s</div>' % diffcontrol)
print_func(u'<div><span class="source">%s</span>'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment