Web Inspector: Show suggest popover on Tab press even if it wasn't showing before
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jul 2015 17:31:57 +0000 (17:31 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jul 2015 17:31:57 +0000 (17:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146496

Reviewed by Timothy Hatcher.

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._handleTabKey): Pressing tab will try to autocomplete before trying
to add an ending colon/semicolon or highlight the next section of text.

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

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

index 0fdf7c4..f40c7ac 100644 (file)
@@ -1,3 +1,14 @@
+2015-07-02  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Show suggest popover on Tab press even if it wasn't showing before
+        https://bugs.webkit.org/show_bug.cgi?id=146496
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._handleTabKey): Pressing tab will try to autocomplete before trying
+        to add an ending colon/semicolon or highlight the next section of text.
+
 2015-07-01  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Aggregate profile call information on the backend to drastically reduce profile sizes
index 7f29517..b0aefef 100644 (file)
@@ -556,30 +556,30 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
         var hasEndingSemicolon = trimmedLine.endsWith(";");
 
         if (cursor.ch >= line.trimRight().length - hasEndingSemicolon) {
-            if (!line.includes(":")) {
-                codeMirror.setCursor(cursor.line, line.length);
-                codeMirror.replaceRange(": ", cursor);
-                return;
-            }
+            this._completionController.completeAtCurrentPositionIfNeeded().then(function(result) {
+                if (result !== WebInspector.CodeMirrorCompletionController.UpdatePromise.NoCompletionsFound)
+                    return;
 
-            var replacement = "";
+                var replacement = "";
 
-            if (!hasEndingSemicolon)
-                replacement += ";";
+                if (!hasEndingSemicolon)
+                    replacement += ";";
 
-            if (lastLine)
-                replacement += "\n";
+                if (lastLine)
+                    replacement += "\n";
 
-            if (replacement.length)
-                codeMirror.replaceRange(replacement, {line: cursor.line, ch: trimmedLine.length});
+                if (replacement.length)
+                    codeMirror.replaceRange(replacement, {line: cursor.line, ch: trimmedLine.length});
 
-            if (!nextLine) {
-                codeMirror.setCursor(cursor.line + 1, 0);
-                return;
-            }
+                if (!nextLine) {
+                    codeMirror.setCursor(cursor.line + 1, 0);
+                    return;
+                }
+
+                var colon = nextLine.indexOf(":");
+                codeMirror.setSelection({line: cursor.line + 1, ch: 0}, {line: cursor.line + 1, ch: colon < 0 ? trimmedNextLine.length : colon});
+            }.bind(this));
 
-            var colon = nextLine.indexOf(":");
-            codeMirror.setSelection({line: cursor.line + 1, ch: 0}, {line: cursor.line + 1, ch: colon < 0 ? trimmedNextLine.length : colon});
             return;
         }