diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 0d392f67c..89657327d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -682,3 +682,4 @@ !bug1922766.pdf !issue18956.pdf !issue19083.pdf +!issue19120.pdf diff --git a/test/pdfs/issue19120.pdf b/test/pdfs/issue19120.pdf new file mode 100755 index 000000000..a271b5eb6 Binary files /dev/null and b/test/pdfs/issue19120.pdf differ diff --git a/test/unit/pdf_find_controller_spec.js b/test/unit/pdf_find_controller_spec.js index 408cba67d..ad5dd49f8 100644 --- a/test/unit/pdf_find_controller_spec.js +++ b/test/unit/pdf_find_controller_spec.js @@ -1062,15 +1062,16 @@ describe("pdf_find_controller", function () { await testOnFind({ eventBus }); }); - it("performs a search in a text with compound word on two lines", async function () { + it("performs a search in a text with a compound word on two lines", async function () { const { eventBus, pdfFindController } = await initPdfFindController("issue18693.pdf"); + const query = "hel-Lo"; await testSearch({ eventBus, pdfFindController, state: { - query: "hel-Lo", + query, }, matchesPerPage: [1], selectedMatch: { @@ -1078,7 +1079,28 @@ describe("pdf_find_controller", function () { matchIndex: 0, }, pageMatches: [[6]], - pageMatchesLength: [[7]], + pageMatchesLength: [[query.length]], + }); + }); + + it("performs a search after a compound word on two lines", async function () { + const { eventBus, pdfFindController } = + await initPdfFindController("issue19120.pdf"); + + const query = "a"; + await testSearch({ + eventBus, + pdfFindController, + state: { + query, + }, + matchesPerPage: [3], + selectedMatch: { + pageIndex: 0, + matchIndex: 0, + }, + pageMatches: [[0, 4, 15]], + pageMatchesLength: [[query.length, query.length, query.length]], }); }); diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 71855127a..11e6b7394 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -282,8 +282,7 @@ function normalize(text) { if (p5) { // Compound word with a line break after the hyphen. - positions.push([i - shift + 3, 1 + shift]); - shift += 1; + // Since the \n isn't in the original text, o = 3 and n = 3. shiftOrigin += 1; eol += 1; return p5.replace("\n", "");