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

Stop scrolling the document when "Highlight All" is toggled in the findbar (issue 5561) #10231

Merged
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
16 changes: 15 additions & 1 deletion web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class PDFFindController {
this._dirtyMatch = true;
}
this._state = state;
this._updateUIState(FindState.PENDING);
if (cmd !== 'findhighlightallchange') {
this._updateUIState(FindState.PENDING);
}

this._firstPageCapability.promise.then(() => {
// If the document was closed before searching began, or if the search
Expand All @@ -129,6 +131,7 @@ class PDFFindController {
this._extractText();

const findbarClosed = !this._highlightMatches;
const pendingTimeout = !!this._findTimeout;

if (this._findTimeout) {
clearTimeout(this._findTimeout);
Expand All @@ -153,6 +156,15 @@ class PDFFindController {
if (findbarClosed && this._state.highlightAll) {
this._updateAllPages();
}
} else if (cmd === 'findhighlightallchange') {
// If there was a pending search operation, synchronously trigger a new
// search *first* to ensure that the correct matches are highlighted.
if (pendingTimeout) {
this._nextMatch();
} else {
this._highlightMatches = true;
}
this._updateAllPages(); // Update the highlighting on all active pages.
} else {
this._nextMatch();
}
Expand Down Expand Up @@ -217,6 +229,8 @@ class PDFFindController {
break;
}
return false;
case 'findhighlightallchange':
return false;
}
return true;
}
Expand Down