Skip to content

Commit

Permalink
Merge pull request #18303 from bootleq/findbar-state-entire-word
Browse files Browse the repository at this point in the history
Expose entireWord in updateFindControlState
  • Loading branch information
timvandermeij committed Jun 21, 2024
2 parents ba0e732 + 890c567 commit f9ff613
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/unit/pdf_find_controller_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,4 +1022,36 @@ describe("pdf_find_controller", function () {
pageMatchesLength: [[1, 1, 1, 1, 1, 1, 1, 1, 1]],
});
});

it("dispatches updatefindcontrolstate with correct properties", async function () {
const testOnFind = ({ eventBus }) =>
new Promise(function (resolve) {
const eventState = {
source: this,
type: "",
query: "Foo",
caseSensitive: true,
entireWord: true,
findPrevious: false,
matchDiacritics: false,
};
eventBus.dispatch("find", eventState);

eventBus.on("updatefindcontrolstate", function (evt) {
expect(evt).toEqual(
jasmine.objectContaining({
state: FindState.NOT_FOUND,
previous: false,
entireWord: true,
matchesCount: { current: 0, total: 0 },
rawQuery: "Foo",
})
);
resolve();
});
});

const { eventBus } = await initPdfFindController();
await testOnFind({ eventBus });
});
});
2 changes: 2 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2516,13 +2516,15 @@ function webViewerUpdateFindMatchesCount({ matchesCount }) {
function webViewerUpdateFindControlState({
state,
previous,
entireWord,
matchesCount,
rawQuery,
}) {
if (PDFViewerApplication.supportsIntegratedFind) {
PDFViewerApplication.externalServices.updateFindControlState({
result: state,
findPrevious: previous,
entireWord,
matchesCount,
rawQuery,
});
Expand Down
1 change: 1 addition & 0 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ class PDFFindController {
source: this,
state,
previous,
entireWord: this.#state?.entireWord ?? null,
matchesCount: this.#requestMatchesCount(),
rawQuery: this.#state?.query ?? null,
});
Expand Down

0 comments on commit f9ff613

Please sign in to comment.