From d7941b4ce741619bcd917dc3c9a762701f355fbc Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 3 Nov 2018 11:52:48 +0100 Subject: [PATCH] Add a helper method, in `PDFFindController`, to determine if matches need to be re-calculated when a new search operation occurs --- web/pdf_find_controller.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 2411a9705..7279a6ae5 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -113,7 +113,7 @@ class PDFFindController { executeCommand(cmd, state) { const pdfDocument = this._pdfDocument; - if (this._state === null || cmd !== 'findagain') { + if (this._state === null || this._shouldDirtyMatch(cmd)) { this._dirtyMatch = true; } this._state = state; @@ -198,6 +198,14 @@ class PDFFindController { return this._normalizedQuery; } + _shouldDirtyMatch(cmd) { + switch (cmd) { + case 'findagain': + return false; + } + return true; + } + /** * Helper for multi-term search that fills the `matchesWithLength` array * and handles cases where one search term includes another search term (for