Skip to content

Commit 194805d

Browse files
authored
Fix RegExp 'd' flag compatibility issue in limited_split function (#4514)
- Remove unsupported 'd' flag from RegExp constructor - Use match.index instead of match.indices for broader compatibility - Fixes 'Invalid flags: dg' error when test suite delimiters are used - Resolves issues with gtest-style test names like 'TestSuite.TestCase'
1 parent b07df43 commit 194805d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ctest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,17 +698,17 @@ export class CTestDriver implements vscode.Disposable {
698698
if (maxCount === 0) {
699699
maxCount = Number.MAX_SAFE_INTEGER;
700700
}
701-
const delimiterRegExp = new RegExp(regexString, 'dg');
701+
const delimiterRegExp = new RegExp(regexString, 'g');
702702
const parts = [];
703703
let lastStart = 0;
704704
while (parts.length < maxCount) {
705-
const match: any = delimiterRegExp.exec(subject);
706-
if (match === null || match.indices === null) {
705+
const match = delimiterRegExp.exec(subject);
706+
if (match === null) { // Remove match.indices check
707707
break;
708708
}
709709

710-
parts.push(subject.substring(lastStart, match.indices[0][0]));
711-
lastStart = match.indices[0][1];
710+
parts.push(subject.substring(lastStart, match.index!));
711+
lastStart = match.index! + match[0].length;
712712
}
713713

714714
parts.push(subject.substring(lastStart));

0 commit comments

Comments
 (0)