Issue 134: Inline comments with code snippets unevenly formatted
Status:  Released
Owner:
Closed:  Oct 2012
Reported by code-rev...@gtempaccount.com, Sep 24, 2009
Reported by Dave Bort <dbort@android.com> on Tue Apr 14 16:45:14 PDT 2009
Source: JIRA GERRIT-134
Affected Version: 2.0.9

I just made an inline comment on a change (on a private gerrit instance,
v2.0.9), with these contents:

======
This block is kind of mysterious, and could probably use a comment.  If "not
k" then k is, what, None?  And if there are multiple "not k" cases, this ends
up setting "key_passwords[None] = None" multiple times.

If this is the desired behavior, it might be more clear to have something like:

key_passwords[None] = None  # comment explaining why
for k in sorted(keylist):
 if not k:
   continue
 p = subprocess...


Though if the current code gives you what you need, then just a comment
calling out the fact that "key_passwords[None] = None" could be called
multiple times, and why, would be fine.
======

The text edit box and the email preserved my newlines and spacing as I entered
them.

However, whenever this comment is rendered as HTML, it formats the code
snippet unevenly, showing:

======
key_passwords[None] = None # comment explaining why for k in sorted(keylist):
if not k:
continue
p = subprocess...
======

The text "key_pass...sorted(keylist):" is rendered in variable-width font, and
"if not...subprocess" is rendered in monospace.  This happens on the side-by-
side view (after publishing) as well as on the "publish comments" page.

It looks like it's trying to treat the code block specially, but is getting
confused somewhere.  See the attached screenshot.
comment-formatting.png
39.4 KB   View   Download
Sep 24, 2009
#1 code-rev...@gtempaccount.com
Comment by Shawn Pearce <sop@google.com> on Tue Apr 14 16:48:19 PDT 2009

You should have indented the entire code block at least one space to get
"code" formatting.  Otherwise it assumes "paragraph" formatting and permits
free-flowing of the text by the browser.
Sep 24, 2009
#2 code-rev...@gtempaccount.com
Comment by Dave Bort <dbort@android.com> on Tue Apr 14 16:53:58 PDT 2009

Hm, ok, noted. Secret feature :)
But even with that, I would have expected there to be a newline between the
non-code lines and the first code line; in this case, the first chunk of
monospace text started on the same line as the preceding non-mono text.
Sep 24, 2009
#3 code-rev...@gtempaccount.com
Comment by Shawn Pearce <sop@google.com> on Wed Apr 15 14:22:34 PDT 2009

Fixed by https://review.source.android.com/9538 (allows user to immediately
preview comment)
Sep 24, 2009
#4 code-rev...@gtempaccount.com
Update by Shawn Pearce <sop@google.com> on Wed Apr 15 15:44:58 PDT 2009

Fixed in version 2.0.10.
Status: Fixed
Sep 24, 2009
#5 code-rev...@gtempaccount.com
Comment by Shawn Pearce <sop@google.com> on Wed Apr 15 15:44:58 PDT 2009

Really fixed by https://review.source.android.com/9541 as your existing
comment will format correctly when that change is deployed on your server.
Sep 25, 2009
#6 code-rev...@gtempaccount.com
(No comment was entered for this change.)
Labels: FixedIn-2.0.10
Oct 25, 2012
#7 sop@google.com
(No comment was entered for this change.)
Status: Released