Web Inspector: Tabbing in the styles sidebar doesn't highlight the next section of...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jul 2015 18:28:45 +0000 (18:28 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Jul 2015 18:28:45 +0000 (18:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146676

Reviewed by Timothy Hatcher.

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._highlightNextNameOrValue): Modified the logic to only search the
remaining text after the current cursor position.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._handleShiftTabKey): Now only searches for matches before the colon.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186468 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js

index 6108057..af9b4d0 100644 (file)
@@ -1,5 +1,17 @@
 2015-07-07  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Tabbing in the styles sidebar doesn't highlight the next section of text
+        https://bugs.webkit.org/show_bug.cgi?id=146676
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._highlightNextNameOrValue): Modified the logic to only search the
+        remaining text after the current cursor position.
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._handleShiftTabKey): Now only searches for matches before the colon.
+
+2015-07-07  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Option+Click not jumping to resource
         https://bugs.webkit.org/show_bug.cgi?id=146498
 
index 27b78cd..c39c388 100644 (file)
@@ -397,12 +397,14 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
 
     _highlightNextNameOrValue(codeMirror, cursor, text)
     {
-        var match = text.match(/(?:[^:;\s]\s*)+/g);
-        var firstMatch = text.indexOf(match[0]) + match[0].length;
-        var nextHead = cursor.ch < firstMatch ? text.indexOf(match[0]) : text.indexOf(match[1]);
-        var nextAnchor = cursor.ch < firstMatch ? firstMatch : text.indexOf(match[1]) + match[1].length;
+        var colonIndex = text.indexOf(":");
+        var substringIndex = colonIndex >= 0 && cursor.ch >= colonIndex ? colonIndex : 0;
 
-        codeMirror.setSelection({line: cursor.line, ch: nextHead}, {line: cursor.line, ch: nextAnchor});
+        var regExp = /(?:[^:;\s]\s*)+/g;
+        regExp.lastIndex = substringIndex;
+        var match = regExp.exec(text);
+
+        codeMirror.setSelection({line: cursor.line, ch: match.index}, {line: cursor.line, ch: match.index + match[0].length});
     }
 
     _handleMouseDown(event)
@@ -525,12 +527,8 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
             return switchRule.call(this);
         }
 
-        var match = line.match(/(?:[^:;\s]\s*)+/g);
-        var lastMatch = line.indexOf(match.lastValue) + match.lastValue.length;
-        var prevHead = cursor.ch > lastMatch ? line.indexOf(match.lastValue) : line.indexOf(match[0]);
-        var prevAnchor = cursor.ch > lastMatch ? lastMatch : line.indexOf(match[0]) + match[0].length;
-
-        codeMirror.setSelection({line: cursor.line, ch: prevHead}, {line: cursor.line, ch: prevAnchor});
+        var match = /(?:[^:;\s]\s*)+/.exec(line);
+        codeMirror.setSelection({line: cursor.line, ch: match.index}, {line: cursor.line, ch: match.index + match[0].length});
     }
 
     _handleTabKey(codeMirror)