Skip to content

Commit

Permalink
Fix structure matching first row and header special character bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
LightFLP committed Dec 14, 2023
1 parent 653e21d commit ac057e8
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/viewer/hooks/useStructureRegularExpressionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ const getLineEndString = (amountOfWhiteSpace: number): string => {

function getHeaderValue(text: string) {
let headerValue = text;
const regExpCarriageReturnAtEnd = /\r$/;

if (regExpCarriageReturnAtEnd.test(headerValue))
headerValue = headerValue.replace(regExpCarriageReturnAtEnd, "\\\\r");

headerValue = `"${headerValue}"`;
headerValue = `"${escapeSpecialChars(headerValue)}"`;

return headerValue;
}
Expand Down Expand Up @@ -238,8 +234,6 @@ export const useStructureRegularExpressionSearch = (
const perfEnd = performance.now();
console.log(`Execution time (regular expression run): ${perfEnd - perfStart} ms`);

console.log(textRanges);

const transStart = performance.now();

textRanges.forEach((matchRanges) => {
Expand All @@ -248,14 +242,15 @@ export const useStructureRegularExpressionSearch = (
const indexOfFirstObjectInMatch = logEntryCharIndexMaps.firstCharIndexMap.get(matchRanges[0]);
const indexOfLastObjectInMatch = logEntryCharIndexMaps.lastCharIndexMap.get(matchRanges[1]);

if (indexOfFirstObjectInMatch && indexOfLastObjectInMatch) {
if (indexOfFirstObjectInMatch != undefined && indexOfLastObjectInMatch != undefined) {

for (let i = indexOfFirstObjectInMatch; i <= indexOfLastObjectInMatch; i++) {
indexesOfEntriesInMatch.push(i);
}

resultingMatches.push(indexesOfEntriesInMatch);
}

});

const transEnd = performance.now();
Expand Down

0 comments on commit ac057e8

Please sign in to comment.