Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that PDFFindController._requestMatchesCount won't return broken data when searching starts (PR 10052 follow-up) #10060

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,20 @@ class PDFFindController {

_requestMatchesCount() {
const { pageIdx, matchIdx, } = this.selected;
let current = 0;
let current = 0, total = this.matchesCountTotal;
if (matchIdx !== -1) {
for (let i = 0; i < pageIdx; i++) {
current += (this.pageMatches[i] && this.pageMatches[i].length) || 0;
}
current += matchIdx + 1;
}
return { current, total: this.matchesCountTotal, };
// When searching starts, this method may be called before the `pageMatches`
// have been counted (in `_calculateMatch`). Ensure that the UI won't show
// temporarily broken state when the active find result doesn't make sense.
if (current > total) {
current = total = 0;
}
return { current, total, };
}

_updateUIResultsCount() {
Expand Down