#454: a few minor enhancements
 - cosmetic changes for the comment editor, which is now aligned with the preview and other comments
 - don't show the ''Add comment'' and regular field modification form when editing a comment
 - add a helper `comment_is_edited` variable in the template

diff --git a/trac/htdocs/css/ticket.css b/trac/htdocs/css/ticket.css
--- a/trac/htdocs/css/ticket.css
+++ b/trac/htdocs/css/ticket.css
@@ -73,11 +73,11 @@
  float: right;
  position: relative;
  bottom: 0.3em;
+ margin-left: 0.2em;
 }
 
 #changelog { border: 1px outset #996; padding: 1em }
-#trac-edited_comment { margin-left: -1px; margin-right: -1px; width: 100% }
-#changelog .wikitoolbar { margin-left: -1px }
+#trac-comment-editor { margin-left: 2em; }
 #preview { border: 1px solid #d7d7d7; padding: 1em }
 #preview h3, #changelog h3 {
  border-bottom: 1px solid #d7d7d7;
@@ -85,7 +85,10 @@
  font-size: 100%;
  font-weight: normal;
 }
-.threading, #changelog .inlinebuttons { float: right; }
+.threading, #changelog .inlinebuttons { 
+ float: right;
+ margin-left: 0.2em;
+}
 .threading { font-size: 85%; }
 
 #preview .changes, #changelog .changes { list-style: square; margin-left: 2em; padding: 0 }
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
--- a/trac/ticket/templates/ticket.html
+++ b/trac/ticket/templates/ticket.html
@@ -49,33 +49,35 @@
     </py:def>
 
     <py:def function="display_change(change)">
-      <ul py:if="change.fields" class="changes">
-        <li py:for="field_name, field in change.fields.items()">
-          <strong>${field_labels[field_name]}</strong>
-          <py:choose>
-            <py:when test="field_name == 'attachment'">
-              <a href="${href.attachment('ticket', ticket.id, field.new)}"><em>${field.new}</em></a> 
-              <a href="${href('raw-attachment', 'ticket', ticket.id, field.new)}"
-                 title="${_('Download')}" class="trac-rawlink"><img src="${chrome.htdocs_location}download.png" alt="${_('Download')}"/></a> 
-              added
-            </py:when>
-            <py:when test="'rendered' in field">${field.rendered}</py:when>
-            <py:when test="field.old and field.new">
-              changed from <em>${field.old}</em> to <em>${field.new}</em>
-            </py:when>
-            <py:when test="not field.old and field.new">
-              set to <em>${field.new}</em>
-            </py:when>
-            <py:otherwise>
-              <em>${field.old}</em> deleted
-            </py:otherwise>
-          </py:choose>
-        </li>
-      </ul>
-      <div py:if="'comment' in change and (str(change.cnum) != cnum_edit or edited_comment is not None)"
-           class="comment searchable ${str(change.cnum) == cnum_edit and 'ticketdraft' or None}" xml:space="preserve">
-        ${wiki_to_html(context, [change.comment, edited_comment][str(change.cnum) == cnum_edit], escape_newlines=preserve_newlines)}
-      </div>
+      <py:with vars="comment_is_edited = str(change.cnum) == cnum_edit">
+        <ul py:if="change.fields" class="changes">
+          <li py:for="field_name, field in change.fields.items()">
+            <strong>${field_labels[field_name]}</strong>
+            <py:choose>
+              <py:when test="field_name == 'attachment'">
+                <a href="${href.attachment('ticket', ticket.id, field.new)}"><em>${field.new}</em></a> 
+                <a href="${href('raw-attachment', 'ticket', ticket.id, field.new)}"
+                   title="${_('Download')}" class="trac-rawlink"><img src="${chrome.htdocs_location}download.png" alt="${_('Download')}"/></a> 
+                added
+              </py:when>
+              <py:when test="'rendered' in field">${field.rendered}</py:when>
+              <py:when test="field.old and field.new">
+                changed from <em>${field.old}</em> to <em>${field.new}</em>
+              </py:when>
+              <py:when test="not field.old and field.new">
+                set to <em>${field.new}</em>
+              </py:when>
+              <py:otherwise>
+                <em>${field.old}</em> deleted
+              </py:otherwise>
+            </py:choose>
+          </li>
+        </ul>
+        <div py:if="'comment' in change and (not comment_is_edited or edited_comment is not None)"
+             class="comment searchable ${comment_is_edited and 'ticketdraft' or None}" xml:space="preserve">
+          ${wiki_to_html(context, (change.comment, edited_comment)[comment_is_edited], escape_newlines=preserve_newlines)}
+        </div>
+      </py:with>
     </py:def>
 
     <div id="content" class="ticket" 
@@ -216,7 +218,7 @@
           <h2>Change History</h2>
           <div id="changelog">
             <py:for each="change in changes">
-              <div class="change">
+              <div class="change" py:with="comment_is_edited = str(change.cnum) == cnum_edit">
                 <h3 class="change">
                   <span class="threading" py:if="'cnum' in change"
                         py:with="change_replies = replies.get(str(change.cnum), [])">
@@ -234,7 +236,7 @@
                   </span>
                   <i18n:msg params="date, author">Changed ${dateinfo(change.date)} ago by ${authorinfo(change.author)}</i18n:msg>
                 </h3>
-                <div py:if="not (can_edit_comment and str(change.cnum) == cnum_edit)" class="inlinebuttons">
+                <div py:if="not (can_edit_comment and comment_is_edited)" class="inlinebuttons">
                   <form py:if="'cnum' in change and can_append" 
                         method="get" action="#comment" class="inlinebuttons">
                     <div>
@@ -251,12 +253,12 @@
                   </form>              
                 </div>
                 ${display_change(change)}
-                <form py:if="can_edit_comment and str(change.cnum) == cnum_edit" method="post" action="#comment:${change.cnum}">
+                <form id="trac-comment-editor" py:if="can_edit_comment and comment_is_edited" method="post" action="#comment:${change.cnum}">
                   <div>
-                    <textarea id="trac-edited_comment" name="edited_comment" class="wikitext" rows="10" cols="78">
+                    <textarea name="edited_comment" class="wikitext" rows="10" cols="78">
 ${[edited_comment, change.comment][edited_comment is None]}</textarea>
                     <input type="hidden" name="cnum_edit" value="${change.cnum}"/>
-                    <input type="submit" name="preview_comment" value="${_('Preview')}" title='Preview changes to comment ${change.cnum}'/>
+                    <input type="submit" name="preview_comment" value="${_('Preview')}" title="Preview changes to comment ${change.cnum}"/>
                     <input type="submit" name="edit_comment" value="${_('Submit changes')}" title="Submit changes to comment ${change.cnum}"/>
                     <input type="submit" name="cancel_comment" value="${_('Cancel')}" title="Cancel comment edit"/>
                   </div>
@@ -268,7 +270,7 @@
       </py:if>
       <!--! End of the section we don't show on initial new tickets -->
 
-      <form py:if="not version and version != 0 and (can_append or can_modify or can_edit or can_create)"
+      <form py:if="not version and version != 0 and not cnum_edit and (can_append or can_modify or can_edit or can_create)"
             action="${ticket.exists and href.ticket(ticket.id) or href.newticket()}" method="post" id="propertyform">
         <h3 py:if="ticket.exists"><a id="edit" onfocus="$('#comment').get(0).focus()">
             Add/Change #${ticket.id} ($ticket.summary)</a></h3>

