GNOME Bugzilla – Bug 600241
Asterisk in javascript regular expression highlighted as a comment
Last modified: 2011-05-26 17:25:48 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
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.
+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).
FWIW, gedit's Ruby syntax highlighting correctly detects regex literals, so the code already exists in principle.
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.
Can we get another look at this bug?
+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.
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 on attachment 151449 [details] [review] Patch to add regex literal support for JavaScript syntax highlighting Can you provide a git format-patch?
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.
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.
Thank /YOU/ Ignacio!
thank Carnë not me ;)