| Index: third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js b/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js
|
| index 1b69fe2345ef85fb61f9d2b27115dbb64e2ece01..3ada5768ff598c8a3a06aef3c86f6c5e007fe0c7 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js
|
| @@ -10,10 +10,11 @@
|
| QuickOpen.FilteredListWidget = class extends UI.VBox {
|
| /**
|
| * @param {!QuickOpen.FilteredListWidget.Delegate} delegate
|
| + * @param {!Array<string>=} promptHistory
|
| */
|
| - constructor(delegate) {
|
| + constructor(delegate, promptHistory) {
|
| super(true);
|
| -
|
| + this._promptHistory = promptHistory || [];
|
| this._renderAsTwoRows = delegate.renderAsTwoRows();
|
|
|
| this.contentElement.classList.add('filtered-list-widget');
|
| @@ -160,7 +161,7 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
|
| // Detach dialog before allowing delegate to override focus.
|
| if (this._dialog)
|
| this._dialog.detach();
|
| - this._delegate.selectItemWithQuery(selectedIndexInDelegate, this._value());
|
| + this._selectItemWithQuery(selectedIndexInDelegate, this._value());
|
| }
|
|
|
| _itemsLoaded() {
|
| @@ -234,7 +235,15 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
|
|
|
| _tabKeyPressed() {
|
| var userEnteredText = this._prompt.text();
|
| - var completion = this._delegate.autocomplete(userEnteredText);
|
| + var completion;
|
| + for (var i = this._promptHistory.length - 1; i >= 0; i--) {
|
| + if (this._promptHistory[i] !== userEnteredText && this._promptHistory[i].startsWith(userEnteredText)) {
|
| + completion = this._promptHistory[i];
|
| + break;
|
| + }
|
| + }
|
| + if (!completion)
|
| + return;
|
| this._prompt.setText(completion);
|
| this._prompt.setDOMSelection(userEnteredText.length, completion.length);
|
| this._scheduleFilter();
|
| @@ -418,7 +427,18 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
|
| // Detach dialog before allowing delegate to override focus.
|
| if (this._dialog)
|
| this._dialog.detach();
|
| - this._delegate.selectItemWithQuery(this._list.selectedItem(), this._value());
|
| + this._selectItemWithQuery(this._list.selectedItem(), this._value());
|
| + }
|
| +
|
| + /**
|
| + * @param {?number} itemIndex
|
| + * @param {string} promptValue
|
| + */
|
| + _selectItemWithQuery(itemIndex, promptValue) {
|
| + this._promptHistory.push(promptValue);
|
| + if (this._promptHistory.length > 100)
|
| + this._promptHistory.shift();
|
| + this._delegate.selectItem(itemIndex, promptValue);
|
| }
|
| };
|
|
|
| @@ -428,13 +448,6 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
|
| */
|
| QuickOpen.FilteredListWidget.Delegate = class {
|
| /**
|
| - * @param {!Array<string>} promptHistory
|
| - */
|
| - constructor(promptHistory) {
|
| - this._promptHistory = promptHistory;
|
| - }
|
| -
|
| - /**
|
| * @param {function():void} refreshCallback
|
| */
|
| setRefreshCallback(refreshCallback) {
|
| @@ -500,17 +513,6 @@ QuickOpen.FilteredListWidget.Delegate = class {
|
| * @param {?number} itemIndex
|
| * @param {string} promptValue
|
| */
|
| - selectItemWithQuery(itemIndex, promptValue) {
|
| - this._promptHistory.push(promptValue);
|
| - if (this._promptHistory.length > 100)
|
| - this._promptHistory.shift();
|
| - this.selectItem(itemIndex, promptValue);
|
| - }
|
| -
|
| - /**
|
| - * @param {?number} itemIndex
|
| - * @param {string} promptValue
|
| - */
|
| selectItem(itemIndex, promptValue) {
|
| }
|
|
|
| @@ -527,18 +529,6 @@ QuickOpen.FilteredListWidget.Delegate = class {
|
| }
|
|
|
| /**
|
| - * @param {string} query
|
| - * @return {string}
|
| - */
|
| - autocomplete(query) {
|
| - for (var i = this._promptHistory.length - 1; i >= 0; i--) {
|
| - if (this._promptHistory[i] !== query && this._promptHistory[i].startsWith(query))
|
| - return this._promptHistory[i];
|
| - }
|
| - return query;
|
| - }
|
| -
|
| - /**
|
| * @return {string}
|
| */
|
| notFoundText() {
|
|
|