My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 249: syntax coloring shouldn't interpret/color the text inside comments
  Back to list
Status:  Released
Owner:  code-rev...@gtempaccount.com
Closed:  Oct 2012


Sign in to add a comment
 
Reported by code-rev...@gtempaccount.com, Sep 24, 2009
Reported by Andrew D. Stadler (Google) <stadler@android.com> on Sat Jul 18 22:48:52 PDT 2009
Source: JIRA GERRIT-250

The syntax coloring is triggering inside comments, which makes for some very
odd (and sometimes questionable) coloring.

For a quick example, just take a look at the standard android/apache header in
almost any java file, which is displayed in multiple colors.

This also comes out kind of weirdly:
 /*
  * Since this field is considered optional, we don't set this here. If
  * the user fills in a value we'll reset the current value, otherwise we
  * just leave the saved value alone.
  *
  * But let's set the hint, so that at least the user knows what's going to
happen if
  * he doesn't fill anything in.
  */
Try that in some code - note:
  The first /* is red
  The first "Since" is red
  The various apostrophes trigger arbitrary green spans.

Overall, it's doing reasonably well in real code, but it needs to recognize
comments and color them all uniformly.
Sep 24, 2009
#1 code-rev...@gtempaccount.com
Comment by Shawn Pearce <sop@google.com> on Mon Jul 20 12:27:51 PDT 2009

I spent half a day on this, and am giving up for now.  :-(

My initial attempt was to expand out both sides of the file and format them as-
is, then split that formatted result apart and display the relevant lines.
This turned out to run very slowly, especially for "Show full files" as we
were prettifying two complete copies of the file (old version and new
version).  The prettify routine is also creating HTML spans that span multiple
lines, which then makes it impossible to just split on line breaks and display
only the relevant sections again.

What we probably have to do is keep track ourselves whether or not we are in a
multi-line comment before prettifying a line, and if we are, inject the
language specific multi-line comment begin marker into the string before
prettifying, and removing it after prettifying.  Since the multi-line comment
marker is language specific it gets messy fast, but we may be OK to just
assume /* for C like languages.
Sep 24, 2009
#2 code-rev...@gtempaccount.com
Comment by Shawn Pearce <sop@google.com> on Mon Jul 20 15:52:18 PDT 2009

Fixed by https://review.source.android.com/10732
Sep 24, 2009
#3 code-rev...@gtempaccount.com
Update by Shawn Pearce <sop@google.com> on Mon Jul 20 15:52:18 PDT 2009

Fixed in version 2.0.17.
Status: Fixed
Sep 25, 2009
#4 code-rev...@gtempaccount.com
(No comment was entered for this change.)
Labels: FixedIn-2.0.17
Oct 21, 2012
#5 sop@google.com
(No comment was entered for this change.)
Status: Released
Sign in to add a comment

Powered by Google Project Hosting