Small hack to fix a potential infinite loop
This commit is contained in:
@@ -71,11 +71,13 @@ $: {
|
|||||||
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
|
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
|
||||||
const groups: SearchMatch[][] = []
|
const groups: SearchMatch[][] = []
|
||||||
let lastOffset = -1
|
let lastOffset = -1
|
||||||
|
let count = 0 // TODO: FIXME: this is a hack to avoid infinite loops
|
||||||
while (true) {
|
while (true) {
|
||||||
const group = getGroupedMatches(matches, lastOffset, excerptAfter)
|
const group = getGroupedMatches(matches, lastOffset, excerptAfter)
|
||||||
if (!group.length) break
|
if (!group.length) break
|
||||||
lastOffset = group.last()!.offset
|
lastOffset = group.last()!.offset
|
||||||
groups.push(group)
|
groups.push(group)
|
||||||
|
if (++count > 100) break
|
||||||
}
|
}
|
||||||
return groups
|
return groups
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user