Attempt to improve readability of PDFFindController.executeCommand by (slightly) refactoring the code responsible for calling PDFFindController._nextMatch

Unfortunately the `PDFFindController.executeCommand` method has now become a bit more complicated than one would like, but hopefully this small change will improve the structure somewhat (especially for subsequent patches).
This commit is contained in:
Jonas Jenwald 2018-10-30 11:08:03 +01:00
parent ec76aa531e
commit af99d1dc08

View File

@ -128,6 +128,8 @@ class PDFFindController {
}
this._extractText();
const findbarClosed = !this._highlightMatches;
if (this._findTimeout) {
clearTimeout(this._findTimeout);
this._findTimeout = null;
@ -139,14 +141,16 @@ class PDFFindController {
this._nextMatch();
this._findTimeout = null;
}, FIND_TIMEOUT);
} else if (cmd === 'findagain' && !this._dirtyMatch) {
const updateHighlightAll = (!this._highlightMatches &&
this._state.highlightAll);
} else if (this._dirtyMatch) {
// Immediately trigger searching for non-'find' operations, when the
// current state needs to be reset and matches re-calculated.
this._nextMatch();
} else if (cmd === 'findagain') {
this._nextMatch();
// When the findbar was previously closed, and `highlightAll` is set,
// ensure that the matches on all active pages are highlighted again.
if (updateHighlightAll) {
if (findbarClosed && this._state.highlightAll) {
this._updateAllPages();
}
} else {