Skip to content

Commit

Permalink
Merge pull request #171636 from microsoft/tyriar/171428
Browse files Browse the repository at this point in the history
Don't iterate over whole output when matching
  • Loading branch information
Tyriar committed Jan 18, 2023
2 parents e37cad4 + 86dca55 commit e40b4a0
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -653,8 +653,11 @@ function getOutputMatchForCommand(executedMarker: IMarker | undefined, endMarker
if (!executedMarker || !endMarker) {
return undefined;
}
const startLine = executedMarker.line;
const endLine = endMarker.line;
if (endLine === -1) {
return undefined;
}
const startLine = Math.max(executedMarker.line, 0);

const matcher = outputMatcher.lineMatcher;
const linesToCheck = typeof matcher === 'string' ? 1 : outputMatcher.length || countNewLines(matcher);
Expand All @@ -669,8 +672,8 @@ function getOutputMatchForCommand(executedMarker: IMarker | undefined, endMarker
}
i = wrappedLineStart;
lines.unshift(getXtermLineContent(buffer, wrappedLineStart, wrappedLineEnd, cols));
if (lines.length > linesToCheck) {
lines.pop();
if (lines.length >= linesToCheck) {
break;
}
if (!match) {
match = lines.join('\n').match(matcher);
Expand All @@ -685,8 +688,8 @@ function getOutputMatchForCommand(executedMarker: IMarker | undefined, endMarker
}
i = wrappedLineEnd;
lines.push(getXtermLineContent(buffer, wrappedLineStart, wrappedLineEnd, cols));
if (lines.length === linesToCheck) {
lines.shift();
if (lines.length >= linesToCheck) {
break;
}
if (!match) {
match = lines.join('\n').match(matcher);
Expand Down

0 comments on commit e40b4a0

Please sign in to comment.