Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js

Issue 2331053002: DevTools: Implement the console prompt with CodeMirror (Closed)
Patch Set: Copyright Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
index b6f69620a227bb71620e552c9f42645b27feb1cc..bf47f5aa99208b6b3b7ecf3b5519d332ba05a3e4 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
@@ -52,8 +52,9 @@ WebInspector.SuggestBoxDelegate.prototype = {
* @constructor
* @param {!WebInspector.SuggestBoxDelegate} suggestBoxDelegate
* @param {number=} maxItemsHeight
+ * @param {boolean=} captureEnter
*/
-WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight)
+WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight, captureEnter)
{
this._suggestBoxDelegate = suggestBoxDelegate;
this._length = 0;
@@ -69,6 +70,8 @@ WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight)
this._asyncDetailsCallback = null;
/** @type {!Map<number, !Promise<{detail: string, description: string}>>} */
this._asyncDetailsPromises = new Map();
+ this._userInteracted = false;
+ this._captureEnter = captureEnter;
}
/**
@@ -161,6 +164,7 @@ WebInspector.SuggestBox.prototype = {
if (!this.visible())
return;
+ this._userInteracted = false;
this._bodyElement.removeEventListener("mousedown", this._maybeHideBound, true);
delete this._bodyElement;
this._container.remove();
@@ -222,6 +226,8 @@ WebInspector.SuggestBox.prototype = {
if (!this._length)
return false;
+ this._userInteracted = true;
+
if (this._selectedIndex === -1 && shift < 0)
shift += 1;
@@ -459,6 +465,9 @@ WebInspector.SuggestBox.prototype = {
*/
enterKeyPressed: function()
{
+ if (!this._userInteracted && this._captureEnter)
+ return false;
+
var hasSelectedItem = !!this._selectedElement || this._onlyCompletion;
this.acceptSuggestion();

Powered by Google App Engine
This is Rietveld 408576698