Skip to content

Commit

Permalink
Don't change view position when toggling Highlight All button
Browse files Browse the repository at this point in the history
Fixes #5561.
  • Loading branch information
Quicksaver committed Dec 15, 2015
1 parent 4876693 commit 3296b4e
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
this.dirtyMatch = true;
}
this.state = e.detail;
this.state.type = e.type;
this.updateUIState(FindStates.FIND_PENDING);

this.firstPagePromise.then(function() {
Expand Down Expand Up @@ -234,13 +235,17 @@ var PDFFindController = (function PDFFindControllerClosure() {
if (this.dirtyMatch) {
// Need to recalculate the matches, reset everything.
this.dirtyMatch = false;
this.selected.pageIdx = this.selected.matchIdx = -1;
this.offset.pageIdx = currentPageIndex;
this.offset.matchIdx = null;
this.hadMatch = false;
this.resumePageIdx = null;
this.pageMatches = [];
this.matchCount = 0;
// When toggling the "Highlight All" button we really only want to
// update the pages to remove the highlights.
if (this.state.type !== 'findhighlightallchange') {
this.selected.pageIdx = this.selected.matchIdx = -1;
this.offset.pageIdx = currentPageIndex;
this.offset.matchIdx = null;
this.hadMatch = false;
this.resumePageIdx = null;
this.pageMatches = [];
this.matchCount = 0;
}
var self = this;

for (var i = 0; i < numPages; i++) {
Expand Down Expand Up @@ -269,8 +274,15 @@ var PDFFindController = (function PDFFindControllerClosure() {
return;
}

// We're specifically looking for a match, make sure it's visible later.
this.showCurrentMatch = true;
if (this.state.type !== 'findhighlightallchange') {
// We're specifically looking for a match, make sure it's visible later.
this.showCurrentMatch = true;
} else {
// Don't look for a next match when just toggling highlights.
var state = FindStates[this.hadMatch ? 'FIND_FOUND' : 'FIND_NOTFOUND'];
this.updateUIState(state);
return;
}

var offset = this.offset;
// Keep track of how many pages we should maximally iterate through.
Expand Down

0 comments on commit 3296b4e

Please sign in to comment.