From 3482b4466bb2961103cd07122ae1c38e95a342c3 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Fri, 27 May 2022 15:00:06 +0200 Subject: [PATCH] Small hack to fix a potential infinite loop --- src/components/ModalInFile.svelte | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/ModalInFile.svelte b/src/components/ModalInFile.svelte index 2ca772d..3e3dbc8 100644 --- a/src/components/ModalInFile.svelte +++ b/src/components/ModalInFile.svelte @@ -71,11 +71,13 @@ $: { function getGroups(matches: SearchMatch[]): SearchMatch[][] { const groups: SearchMatch[][] = [] let lastOffset = -1 + let count = 0 // TODO: FIXME: this is a hack to avoid infinite loops while (true) { const group = getGroupedMatches(matches, lastOffset, excerptAfter) if (!group.length) break lastOffset = group.last()!.offset groups.push(group) + if (++count > 100) break } return groups }