Skip to content

Commit

Permalink
fix:multiLineTextFinder to handle null return value from find method (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
michail-sygk authored Jan 15, 2024
1 parent e41a9f5 commit 9b81cdf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/util/MultiLineTextFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export class MultiLineTextFinder {
} else {
const sourceTextArray = splitTextIntoLineArray(sourceText);
const searchTextArray = splitTextIntoLineArray(searchText);
const lineNo: number = MultiLineTextFinder.find(sourceTextArray, searchTextArray);
if (lineNo) {
const lineNo: number | null = MultiLineTextFinder.find(
sourceTextArray,
searchTextArray,
);
if (lineNo !== null) {
const replacementTextArray = splitTextIntoLineArray(replacementText);
const linesToRemove: number = searchTextArray.length;
sourceTextArray.splice(lineNo, linesToRemove, ...replacementTextArray);
Expand Down

0 comments on commit 9b81cdf

Please sign in to comment.