Chromium Code Reviews| 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(); |