Web Inspector: Command-Enter should evaluate selected JS in Debugger/Sources
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Aug 2015 16:06:21 +0000 (16:06 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Aug 2015 16:06:21 +0000 (16:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148368

Reviewed by Timothy Hatcher.

* UserInterface/Controllers/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController):
(WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
Evaluate selected text in the console only for JS and HTML resources. HTML resources
should be allowed because they can have commented out (inside <!-- -->) and
inline (onclick="") JavaScript.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js

index 77eb3a0..c6e3f20 100644 (file)
@@ -1,3 +1,17 @@
+2015-08-26  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Command-Enter should evaluate selected JS in Debugger/Sources
+        https://bugs.webkit.org/show_bug.cgi?id=148368
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/CodeMirrorCompletionController.js:
+        (WebInspector.CodeMirrorCompletionController):
+        (WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
+        Evaluate selected text in the console only for JS and HTML resources. HTML resources
+        should be allowed because they can have commented out (inside <!-- -->) and
+        inline (onclick="") JavaScript.
+
 2015-08-25  Brian Burg  <bburg@apple.com>
 
         Web Inspector: no need to allocate protocolErrors array for every dispatched backend command
index 617ff2a..4880119 100644 (file)
@@ -51,6 +51,7 @@ WebInspector.CodeMirrorCompletionController = class CodeMirrorCompletionControll
             "Right": this._handleRightOrEnterKey.bind(this),
             "Esc": this._handleEscapeKey.bind(this),
             "Enter": this._handleRightOrEnterKey.bind(this),
+            "Cmd-Enter": this._handleCommandEnterKey.bind(this),
             "Tab": this._handleTabKey.bind(this),
             "Cmd-A": this._handleHideKey.bind(this),
             "Cmd-Z": this._handleHideKey.bind(this),
@@ -723,6 +724,19 @@ WebInspector.CodeMirrorCompletionController = class CodeMirrorCompletionControll
         this._commitCompletionHint();
     }
 
+    _handleCommandEnterKey(codeMirror)
+    {
+        const modeName = codeMirror.getMode().name;
+        if (modeName !== "javascript" && modeName !== "htmlmixed")
+            return CodeMirror.Pass;
+
+        const selectedText = codeMirror.getSelection();
+        if (!selectedText)
+            return CodeMirror.Pass;
+
+        WebInspector.consoleLogViewController.consolePromptTextCommitted(null, selectedText);
+    }
+
     _handleEscapeKey(codeMirror)
     {
         var delegateImplementsShouldAllowEscapeCompletion = this._delegate && typeof this._delegate.completionControllerShouldAllowEscapeCompletion === "function";