Make auto-complete only suggest properties that are valid syntax
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2008 04:50:34 +0000 (04:50 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2008 04:50:34 +0000 (04:50 +0000)
        when using dot-notation. Also when completing numeric properties,
        the quotes are omitted inside the brackets.

        https://bugs.webkit.org/show_bug.cgi?id=21760
        https://bugs.webkit.org/show_bug.cgi?id=21761

        Reviewed by Oliver Hunt.

        * inspector/front-end/Console.js:
        (WebInspector.Console.prototype.completions): Skip properties that
        are not valid identifies when using dot-notation. And omit the quotes
        when completing numbers in bracket-notation.

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

WebCore/ChangeLog
WebCore/inspector/front-end/Console.js

index 90654ff681b71ff3f376d7e93a558f212bde9286..af74a3068dc5598109d2994d943e12b125d13c06 100644 (file)
@@ -1,3 +1,19 @@
+2008-10-20  Timothy Hatcher  <timothy@apple.com>
+
+        Make auto-complete only suggest properties that are valid syntax
+        when using dot-notation. Also when completing numeric properties,
+        the quotes are omitted inside the brackets.
+
+        https://bugs.webkit.org/show_bug.cgi?id=21760
+        https://bugs.webkit.org/show_bug.cgi?id=21761
+
+        Reviewed by Oliver Hunt.
+
+        * inspector/front-end/Console.js:
+        (WebInspector.Console.prototype.completions): Skip properties that
+        are not valid identifies when using dot-notation. And omit the quotes
+        when completing numbers in bracket-notation.
+
 2008-10-20  Timothy Hatcher  <timothy@apple.com>
 
         Fixes the Profiles panel in the Web Inspector, which was broken by
index eecf5e45845d6ded5737523bb8c7eb64b4f1ce6b..e4de88bb898d233ea7000d9b182ae3b497a932dd 100644 (file)
@@ -284,12 +284,21 @@ WebInspector.Console.prototype = {
         var properties = Object.sortedProperties(result);
         for (var i = 0; i < properties.length; ++i) {
             var property = properties[i];
-            if (bracketNotation)
-                property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + quoteUsed + "]";
+
+            if (dotNotation && !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(property))
+                continue;
+
+            if (bracketNotation) {
+                if (!/^[0-9]+$/.test(property))
+                    property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + quoteUsed;
+                property += "]";
+            }
+
             if (property.length < prefix.length)
                 continue;
             if (property.indexOf(prefix) !== 0)
                 continue;
+
             results.push(property);
             if (bestMatchOnly)
                 break;