Title: [188967] trunk/Source/WebInspectorUI
Revision
188967
Author
nvasil...@apple.com
Date
2015-08-26 09:06:21 -0700 (Wed, 26 Aug 2015)

Log Message

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_.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (188966 => 188967)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-08-26 15:53:00 UTC (rev 188966)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-08-26 16:06:21 UTC (rev 188967)
@@ -1,3 +1,17 @@
+2015-08-26  Nikita Vasilyev  <nvasil...@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  <bb...@apple.com>
 
         Web Inspector: no need to allocate protocolErrors array for every dispatched backend command

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (188966 => 188967)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-08-26 15:53:00 UTC (rev 188966)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2015-08-26 16:06:21 UTC (rev 188967)
@@ -51,6 +51,7 @@
             "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 @@
         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";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to