| Index: third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js b/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
|
| index fab103e3cd75237967b1aadd9579034955290831..124e5b44322a49d12e91e46811030ce480ffb56d 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
|
| @@ -445,7 +445,7 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| * @override
|
| */
|
| searchCanceled() {
|
| - delete this._searchQuery;
|
| + delete this._searchConfig;
|
| this._hideSearchHighlights();
|
|
|
| this._searchableView.updateSearchMatchesCount(0);
|
| @@ -464,14 +464,17 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| */
|
| performSearch(searchConfig, shouldJump, jumpBackwards) {
|
| var query = searchConfig.query;
|
| - // Call searchCanceled since it will reset everything we need before doing a new search.
|
| - this.searchCanceled();
|
|
|
| const whitespaceTrimmedQuery = query.trim();
|
| if (!whitespaceTrimmedQuery.length)
|
| return;
|
|
|
| - this._searchQuery = query;
|
| + if (!this._searchConfig || this._searchConfig.query !== query)
|
| + this.searchCanceled();
|
| + else
|
| + this._hideSearchHighlights();
|
| +
|
| + this._searchConfig = searchConfig;
|
|
|
| var promises = [];
|
| var domModels = SDK.DOMModel.instances();
|
| @@ -498,10 +501,18 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| this._searchableView.updateSearchMatchesCount(this._searchResults.length);
|
| if (!this._searchResults.length)
|
| return;
|
| - this._currentSearchResultIndex = -1;
|
| + if (this._currentSearchResultIndex >= this._searchResults.length)
|
| + this._currentSearchResultIndex = undefined;
|
| +
|
| + var index = this._currentSearchResultIndex;
|
|
|
| - if (shouldJump)
|
| - this._jumpToSearchResult(jumpBackwards ? -1 : 0);
|
| + if (shouldJump) {
|
| + if (this._currentSearchResultIndex === undefined)
|
| + index = jumpBackwards ? -1 : 0;
|
| + else
|
| + index = jumpBackwards ? index - 1 : index + 1;
|
| + this._jumpToSearchResult(index);
|
| + }
|
| }
|
| }
|
|
|
| @@ -553,7 +564,6 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| }
|
|
|
| _jumpToSearchResult(index) {
|
| - this._hideSearchHighlights();
|
| this._currentSearchResultIndex = (index + this._searchResults.length) % this._searchResults.length;
|
| this._highlightCurrentSearchResult();
|
| }
|
| @@ -564,7 +574,7 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| jumpToNextSearchResult() {
|
| if (!this._searchResults)
|
| return;
|
| - this._jumpToSearchResult(this._currentSearchResultIndex + 1);
|
| + this.performSearch(this._searchConfig, true);
|
| }
|
|
|
| /**
|
| @@ -573,7 +583,7 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| jumpToPreviousSearchResult() {
|
| if (!this._searchResults)
|
| return;
|
| - this._jumpToSearchResult(this._currentSearchResultIndex - 1);
|
| + this.performSearch(this._searchConfig, true, true);
|
| }
|
|
|
| /**
|
| @@ -621,7 +631,7 @@ Elements.ElementsPanel = class extends UI.Panel {
|
|
|
| var treeElement = this._treeElementForNode(searchResult.node);
|
| if (treeElement) {
|
| - treeElement.highlightSearchResults(this._searchQuery);
|
| + treeElement.highlightSearchResults(this._searchConfig.query);
|
| treeElement.reveal();
|
| var matches = treeElement.listItemElement.getElementsByClassName(UI.highlightedSearchResultClassName);
|
| if (matches.length)
|
| @@ -630,7 +640,7 @@ Elements.ElementsPanel = class extends UI.Panel {
|
| }
|
|
|
| _hideSearchHighlights() {
|
| - if (!this._searchResults || !this._searchResults.length || this._currentSearchResultIndex < 0)
|
| + if (!this._searchResults || !this._searchResults.length || this._currentSearchResultIndex === undefined)
|
| return;
|
| var searchResult = this._searchResults[this._currentSearchResultIndex];
|
| if (!searchResult.node)
|
|
|