GNOME Bugzilla – Bug 685885
javascript: shouldn't find a regexp in [thing / thing, thing / thing]
Last modified: 2015-04-15 08:28:27 UTC
real case: cr.translate(area_width / 2.0, area_height / 2.0) test case: a = [thing / thing, thing / thing] In both cases, the text between the two slashs (including them) is in pink in Gedit, for what I understand as if it was a regexp.
Patches welcomed against the javascript.lang http://git.gnome.org/browse/gtksourceview/tree/data/language-specs/javascript.lang
Created attachment 300985 [details] [review] require special character after regex If I read my javascript.vim correctly, vim requires one of the characters ";.,)]}" after a regex, fixing this issue, so maybe GtkSourceView should do the same. I also added ":" (for ternary operator) and "/" (for comments) in this patch. Does that make sense? I'm not 100% sure that a regex can never be followed by other characters. Also, there's still other false positives, like in this example from the ECMA specification: a = b /hi/g.exec(c).map(d);
Comment on attachment 300985 [details] [review] require special character after regex > \%{regex-opts} >- ([),;.]|\s|$) >+ \s* >+ ([),;.\/\]:}]|$) What fixes the bug is the \s*, not the added characters. Are you sure the added characters are needed? Can you add a JavaScript example file in the tests/syntax-highlighting/ directory? So you can provide an example for each possible character following a regex.
Created attachment 301467 [details] [review] an example file for smoke testing Examples for these characters. I didn't only add the \s* but I also removed the \s from the bracket expression following the \s*. Before that change, any whitespace following a slash was sufficient to qualify it as closing a regex. Now that specific special characters like ),;. are actually required, as was probably originally intended, I wanted to add the remaining ones, to avoid introducing new false negatives.
Review of attachment 301467 [details] [review]: Thanks, I'm not an expert in JS, but it looks good.
Review of attachment 300985 [details] [review]: > I didn't only add the \s* but I also removed the \s from the bracket expression > following the \s*. Oh, right. So I guess the commit is fine.
Commits pushed, thanks. https://git.gnome.org/browse/gtksourceview/commit/?id=8acd14f2bb6d22e98412a527c6e7f712e809fd9f https://git.gnome.org/browse/gtksourceview/commit/?id=fb384c379d7d1453937c7f405f23ae6ef93b3128