Merge pull request #16275 from calixteman/ifx_search_with_fractions
Fix search of numbers inside fractions
This commit is contained in:
commit
7571842d84
@ -381,6 +381,66 @@ describe("pdf_find_controller", function () {
|
|||||||
pageMatches: [[27, 54]],
|
pageMatches: [[27, 54]],
|
||||||
pageMatchesLength: [[1, 1]],
|
pageMatchesLength: [[1, 1]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await testSearch({
|
||||||
|
eventBus,
|
||||||
|
pdfFindController,
|
||||||
|
state: {
|
||||||
|
query: "1",
|
||||||
|
},
|
||||||
|
matchesPerPage: [3],
|
||||||
|
selectedMatch: {
|
||||||
|
pageIndex: 0,
|
||||||
|
matchIndex: 0,
|
||||||
|
},
|
||||||
|
pageMatches: [[27, 54, 55]],
|
||||||
|
pageMatchesLength: [[1, 1, 1]],
|
||||||
|
});
|
||||||
|
|
||||||
|
await testSearch({
|
||||||
|
eventBus,
|
||||||
|
pdfFindController,
|
||||||
|
state: {
|
||||||
|
query: "2",
|
||||||
|
},
|
||||||
|
matchesPerPage: [2],
|
||||||
|
selectedMatch: {
|
||||||
|
pageIndex: 0,
|
||||||
|
matchIndex: 0,
|
||||||
|
},
|
||||||
|
pageMatches: [[27, 54]],
|
||||||
|
pageMatchesLength: [[1, 1]],
|
||||||
|
});
|
||||||
|
|
||||||
|
await testSearch({
|
||||||
|
eventBus,
|
||||||
|
pdfFindController,
|
||||||
|
state: {
|
||||||
|
query: "1/",
|
||||||
|
},
|
||||||
|
matchesPerPage: [3],
|
||||||
|
selectedMatch: {
|
||||||
|
pageIndex: 0,
|
||||||
|
matchIndex: 0,
|
||||||
|
},
|
||||||
|
pageMatches: [[27, 54, 55]],
|
||||||
|
pageMatchesLength: [[1, 1, 1]],
|
||||||
|
});
|
||||||
|
|
||||||
|
await testSearch({
|
||||||
|
eventBus,
|
||||||
|
pdfFindController,
|
||||||
|
state: {
|
||||||
|
query: "1/21",
|
||||||
|
},
|
||||||
|
matchesPerPage: [1],
|
||||||
|
selectedMatch: {
|
||||||
|
pageIndex: 0,
|
||||||
|
matchIndex: 0,
|
||||||
|
},
|
||||||
|
pageMatches: [[54]],
|
||||||
|
pageMatchesLength: [[2]],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("performs a normal search, where the text with diacritics is normalized", async function () {
|
it("performs a normal search, where the text with diacritics is normalized", async function () {
|
||||||
|
@ -350,8 +350,10 @@ function getOriginalIndex(diffs, pos, len) {
|
|||||||
return [pos, len];
|
return [pos, len];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First char in the new string.
|
||||||
const start = pos;
|
const start = pos;
|
||||||
const end = pos + len;
|
// Last char in the new string.
|
||||||
|
const end = pos + len - 1;
|
||||||
let i = binarySearchFirstItem(diffs, x => x[0] >= start);
|
let i = binarySearchFirstItem(diffs, x => x[0] >= start);
|
||||||
if (diffs[i][0] > start) {
|
if (diffs[i][0] > start) {
|
||||||
--i;
|
--i;
|
||||||
@ -362,7 +364,14 @@ function getOriginalIndex(diffs, pos, len) {
|
|||||||
--j;
|
--j;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
|
// First char in the old string.
|
||||||
|
const oldStart = start + diffs[i][1];
|
||||||
|
|
||||||
|
// Last char in the old string.
|
||||||
|
const oldEnd = end + diffs[j][1];
|
||||||
|
const oldLen = oldEnd + 1 - oldStart;
|
||||||
|
|
||||||
|
return [oldStart, oldLen];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user