From 789ecd51dc6a3e81922251f4bbf2720fabcf8148 Mon Sep 17 00:00:00 2001 From: LightFLP Date: Wed, 27 Sep 2023 15:23:39 +0200 Subject: [PATCH] Add Map types in LogEntryCharMaps --- src/viewer/hooks/useStructureRegularExpressionManager.ts | 6 ++++-- src/viewer/types.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/viewer/hooks/useStructureRegularExpressionManager.ts b/src/viewer/hooks/useStructureRegularExpressionManager.ts index 4d3eb56..9bba0e2 100644 --- a/src/viewer/hooks/useStructureRegularExpressionManager.ts +++ b/src/viewer/hooks/useStructureRegularExpressionManager.ts @@ -233,8 +233,10 @@ export const useStructureRegularExpressionSearch = ( const indexOfFirstObjectInMatch = logEntryCharIndexMaps.firstCharIndexMap.get(matchRanges[0]); const indexOfLastObjectInMatch = logEntryCharIndexMaps.lastCharIndexMap.get(matchRanges[1]); - for (let i = indexOfFirstObjectInMatch; i <= indexOfLastObjectInMatch; i++) { - indexesOfEntriesInMatch.push(i); + if(indexOfFirstObjectInMatch && indexOfLastObjectInMatch) { + for (let i = indexOfFirstObjectInMatch; i <= indexOfLastObjectInMatch; i++) { + indexesOfEntriesInMatch.push(i); + } } resultingMatches.push(indexesOfEntriesInMatch); diff --git a/src/viewer/types.d.ts b/src/viewer/types.d.ts index 659c9d3..245709f 100644 --- a/src/viewer/types.d.ts +++ b/src/viewer/types.d.ts @@ -59,6 +59,6 @@ export interface Segment { } export interface LogEntryCharMaps { - firstCharIndexMap; - lastCharIndexMap; + firstCharIndexMap: Map; + lastCharIndexMap: Map; }