Sublime Forum

Bug: Inline Javascript Regex causes coloring to break

#1

I wasn’t sure if this was the right place for bugs.

A regex pattern used in a certain way can break the color coding of a Javascript file. For instance, the following will color the items below it in yellow (default text color)

document.location.href="MyPage.php?page=login&" +MyClass.buildQueryStringFromArray(MyClass.removeStringArrayElement(MyClass.getParameterArray(),/^page=/)) +"&redirect="+encodeURIComponent(document.URL)+"&login-expired=1"; //other stuff below turns yellow
Workaround (obviously a better way to go, but doesn’t fix the bug):

var pageRegex = /^page=/; document.location.href="MyPage.php?page=login&" +MyClass.buildQueryStringFromArray(MyClass.removeStringArrayElement(MyClass.getParameterArray(),pageRegex)) +"&redirect="+encodeURIComponent(document.URL)+"&login-expired=1"; //colors are better now
Thanks.

0 Likes

#2

one more:

var x = 10 / 2; alert(x);

0 Likes

#3

Temporary solution:

Replace following in JavaScript.tmLanguage

650:			<string>(?&lt;==(:]|^|return|&amp;&amp;|\|\||!)\s*(/)(?!/*+{}?])</string>

with

650:			<string>(?&lt;==(:]|,|,\s|return|&amp;&amp;|\|\||!)\s*(/)(?!/*+{}?])</string>
0 Likes