diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 1db2e32bd..a7b2eb0a6 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -172,6 +172,17 @@ class PDFFindController { this._firstPageCapability = createPromiseCapability(); } + /** + * @return {string} The (current) normalized search query. + */ + get _query() { + if (this._state.query !== this._rawQuery) { + this._rawQuery = this._state.query; + this._normalizedQuery = normalize(this._state.query); + } + return this._normalizedQuery; + } + /** * Helper for multi-term search that fills the `matchesWithLength` array * and handles cases where one search term includes another search term (for @@ -307,7 +318,7 @@ class PDFFindController { _calculateMatch(pageIndex) { let pageContent = this._pageContents[pageIndex]; - let query = normalize(this._state.query); + let query = this._query; const { caseSensitive, entireWord, phraseSearch, } = this._state; if (query.length === 0) { @@ -425,7 +436,7 @@ class PDFFindController { } // If there's no query there's no point in searching. - if (this._state.query === '') { + if (this._query === '') { this._updateUIState(FindState.FOUND); return; }