After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 600241 - Asterisk in javascript regular expression highlighted as a comment
Asterisk in javascript regular expression highlighted as a comment
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
unspecified
Other Linux
: Normal trivial
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-31 17:06 UTC by Jared
Modified: 2011-05-26 17:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
An example of the incorrect highlighting. (18.27 KB, image/png)
2009-10-31 17:12 UTC, Jared
  Details
Patch to add regex literal support for JavaScript syntax highlighting (2.19 KB, patch)
2010-01-15 05:59 UTC, Jim R. Wilson
needs-work Details | Review
add regex literal support for JavaScript syntax highlighting (2.74 KB, patch)
2011-05-25 16:40 UTC, Carnë Draug
committed Details | Review

Description Jared 2009-10-31 17:06:33 UTC
While editing Javascript in gedit, I find that I will sometimes have an asterisk at the end of a regular expression. In Javascript, regular expressions are begun and ended with a / (forward slash) instead of quotes. However, gedit identifies any regular expressions with an asterisk as the last letter as the incorrect end of a comment (*/) and highlights the two characters red.

For example, if I have the regular expression:

/\d*/

gedit will highlight the asterisk and forward slash red as if it were an end-comment marker.


This bug was noted in Ubuntu's launchpad but I was told to report this bug upstream.

https://bugs.launchpad.net/ubuntu/+source/gtksourceview2/+bug/465721
Comment 1 Jared 2009-10-31 17:12:42 UTC
Created attachment 146651 [details]
An example of the incorrect highlighting.

The first line shows the incorrect highlighting. The second line shows the workaround that I have done that does not fix the problem, but avoids the incorrect highlight.
Comment 2 Jim R. Wilson 2010-01-15 05:20:47 UTC
+1 for this bug.  It's annoying that gedit doesn't recognize regular expression literals in JavaScript code.  Ideally, they'd be syntax highlighted in a color different from string literals, and stand out (and of course, not highlight */ in red as the bug report explains).
Comment 3 Jim R. Wilson 2010-01-15 05:23:06 UTC
FWIW, gedit's Ruby syntax highlighting correctly detects regex literals, so the code already exists in principle.
Comment 4 Jim R. Wilson 2010-01-15 05:59:34 UTC
Created attachment 151449 [details] [review]
Patch to add regex literal support for JavaScript syntax highlighting

Ripped the appropriate lines from ruby.lang to support regex literals.
Comment 5 Jared 2010-04-23 04:16:18 UTC
Can we get another look at this bug?
Comment 6 lampak 2010-08-06 10:22:21 UTC
+1 for the bug. 
Soon it will be a year after this bug was reported and the patch will by half a year old. But the bug is still "unconfirmed". Great.
Comment 7 Jim R. Wilson 2010-08-06 15:14:52 UTC
Agree with anon.  Please do this committers!

Aside: I'd prefer not to have to hack this in *again* after I upgrade to Maverick Meerkat. :/
Comment 8 Ignacio Casal Quinteiro (nacho) 2010-08-06 20:25:02 UTC
Comment on attachment 151449 [details] [review]
Patch to add regex literal support for JavaScript syntax highlighting

Can you provide a git format-patch?
Comment 9 Carnë Draug 2011-05-25 16:40:56 UTC
Created attachment 188605 [details] [review]
add regex literal support for JavaScript syntax highlighting

Here's the previous patch generated with "format-patch". I used
    Jim R. Wilson <wilson.jim.r@gmail.com>

as value for --author. The only change I made was changing the style of the regex for def:string instead of def:identifier (in similarity to perl).

Note: for this patch to apply, the patches in bug #651061 need to be committed first.
Comment 10 Ignacio Casal Quinteiro (nacho) 2011-05-26 14:25:56 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 11 Jim R. Wilson 2011-05-26 17:19:12 UTC
Thank /YOU/ Ignacio!
Comment 12 Ignacio Casal Quinteiro (nacho) 2011-05-26 17:25:48 UTC
thank Carnë not me ;)