New regex for efficiency

More specific regex used to ensure efficiency & speed are optimal
Syntax spacing adjusts on couple of other lines
This commit is contained in:
Matt Pass
2012-10-06 15:43:23 +01:00
parent 388bd7cefa
commit 0e377c1aff

View File

@@ -1304,13 +1304,13 @@ var ICEcoder = {
// Show a CSS color block next to our text cursor
cssColorPreview: function() {
var cM,string,rx,match,oldBlock,newBlock;
var cM, string, rx, match, oldBlock, newBlock;
cM = ICEcoder.getcMInstance();
string = cM.getLine(cM.getCursor().line);
rx = /(#[\da-f]{3,6}\b|(?:rgb|hsl)a?\([^)]*\)|[a-z]+\b)/gi;
rx = /(#[\da-f]{3}(?:[\da-f]{3})?\b|\b(?:rgb|hsl)a?\([\s\d%,.-]+\)|\b[a-z]+\b)/gi;
while((match = rx.exec(string)) && cM.getCursor().ch > match.index + match[0].length);
while((match = rx.exec(string)) && cM.getCursor().ch > match.index+match[0].length);
oldBlock = top.document.getElementById('content').contentWindow.document.getElementById('cssColor');
if (oldBlock) {oldBlock.parentNode.removeChild(oldBlock)};