From 40fe10ec958be6eee57072a73befd42131f78df9 Mon Sep 17 00:00:00 2001 From: "timothy@apple.com" Date: Tue, 21 Oct 2008 04:50:34 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@37757 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 16 ++++++++++++++++ WebCore/inspector/front-end/Console.js | 13 +++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 90654ff681b7..af74a3068dc5 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2008-10-20 Timothy Hatcher + + 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 Fixes the Profiles panel in the Web Inspector, which was broken by diff --git a/WebCore/inspector/front-end/Console.js b/WebCore/inspector/front-end/Console.js index eecf5e45845d..e4de88bb898d 100644 --- a/WebCore/inspector/front-end/Console.js +++ b/WebCore/inspector/front-end/Console.js @@ -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; -- 2.36.0