From f41908a1f7b5a100ae1f4f143ac8f150d1d83f73 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 12 Mar 2013 23:04:56 -0400 Subject: [PATCH] command:html: Rework comment
closing Comment nesting wasn't working properly before, where you could get things like:
from a comment tree (using fake ids) of: . |-- a | `-- a/b | `-- a/b/c `-- d The new handling pushes the `div_close(depth)` call to the front of the comment block, because a comment's depth tells us how many of the already-rendered comments we need to close. Closing comments at the top of the block means that we'll always have at least one unclosed comment to close after the comment loop completes. With the new handling, we'll get a more appropriate:
Reported-by: Owen Jacobson --- libbe/command/html.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libbe/command/html.py b/libbe/command/html.py index 2b7dcf8..5186417 100644 --- a/libbe/command/html.py +++ b/libbe/command/html.py @@ -698,6 +698,7 @@ div.root.comment { {% if comments %} {% for depth,comment in comments %} +{{ div_close(depth) }} {% if depth == 0 %}
{% else %} @@ -707,11 +708,8 @@ div.root.comment { 'depth':depth, 'bug': bug, 'comment':comment, 'comment_dir':comment_dir, 'format_body': format_body, 'div_close': div_close, 'strip_email': strip_email}) }} -{{ div_close(depth) }} {% endfor %} -{% if comments[-1][0] > 0 %} {{ div_close(0) }} -{% endif %} {% else %}

No comments.

{% endif %} @@ -953,7 +951,7 @@ Html = HTML # alias for libbe.command.base.get_command_class() class _DivCloser (object): - def __init__(self, depth=0): + def __init__(self, depth=-1): self.depth = depth def __call__(self, depth): -- 2.26.2