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

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

Issue 2319393002: DevTools: Fix race condition in TextPrompt completions (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
index ffd47423e462767910bb2081411566c8cbaf4850..b40400ad7524c86ed10333a7930ab763874ed15f 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
@@ -45,6 +45,7 @@ WebInspector.TextPrompt = function(completions, stopCharacters)
this._completionStopCharacters = stopCharacters || " =:[({;,!+-*/&|^<>.";
this._autocompletionTimeout = WebInspector.TextPrompt.DefaultAutocompletionTimeout;
this._title = "";
+ this._completionsCounter = 0;
lushnikov 2016/09/08 14:45:50 let's name it _completionRequestId
einbinder 2016/09/08 17:49:16 Done.
}
WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250;
@@ -380,7 +381,6 @@ WebInspector.TextPrompt.prototype = {
clearTimeout(this._completeTimeout);
delete this._completeTimeout;
}
- delete this._waitingForCompletions;
if (!this.autoCompleteElement)
return;
@@ -431,8 +431,7 @@ WebInspector.TextPrompt.prototype = {
}
var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, this._completionStopCharacters, this._element, "backward");
- this._waitingForCompletions = true;
- this._loadCompletions(/** @type {!Element} */ (this._proxyElement), wordPrefixRange, force || false, this._completionsReady.bind(this, selection, wordPrefixRange, !!reverse, !!force));
+ this._loadCompletions(/** @type {!Element} */ (this._proxyElement), wordPrefixRange, force || false, this._completionsReady.bind(this, selection, wordPrefixRange, !!reverse, !!force, ++this._completionsCounter));
},
disableDefaultSuggestionForEmptyInput: function()
@@ -500,10 +499,11 @@ WebInspector.TextPrompt.prototype = {
* @param {!Range} originalWordPrefixRange
* @param {boolean} reverse
* @param {boolean} force
+ * @param {number} completionsCounter
lushnikov 2016/09/08 14:45:50 let's make it the very first one and name it compl
einbinder 2016/09/08 17:49:16 Done.
* @param {!Array.<string>} completions
* @param {number=} selectedIndex
*/
- _completionsReady: function(selection, originalWordPrefixRange, reverse, force, completions, selectedIndex)
+ _completionsReady: function(selection, originalWordPrefixRange, reverse, force, completionsCounter, completions, selectedIndex)
{
var prefix = originalWordPrefixRange.toString();
@@ -519,13 +519,11 @@ WebInspector.TextPrompt.prototype = {
annotatedCompletions = this.additionalCompletions(prefix).concat(annotatedCompletions);
}
- if (!this._waitingForCompletions || !annotatedCompletions.length) {
+ if (this._completionsCounter !== completionsCounter || !annotatedCompletions.length) {
lushnikov 2016/09/08 14:45:50 let's bail out in the very beginning of the callba
einbinder 2016/09/08 17:49:16 Done.
this.clearAutoComplete();
return;
}
- delete this._waitingForCompletions;
-
var selectionRange = selection.getRangeAt(0);
var fullWordRange = this._createRange();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698