Skip to content
Snippets Groups Projects
Commit 4afa1ccd authored by Ximin Luo's avatar Ximin Luo
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -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">')
try:
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>'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment