Skip to content

Commit edf2db6

Browse files
committed
Add some more cancellation checks
1 parent 187a89b commit edf2db6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/providers/FileSystemProvider/TextSearchProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,17 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
326326
const contentLength = content.length;
327327
// Find all lines that we have matches on
328328
const lines = file.matches
329-
.map((match: SearchMatch) => searchMatchToLine(content, match, file.doc, api.configName))
329+
.map((match: SearchMatch) =>
330+
token.isCancellationRequested ? null : searchMatchToLine(content, match, file.doc, api.configName)
331+
)
330332
.filter(notNull);
331333
// Remove duplicates and make them quickly searchable
332334
const matchedLines = new Set(lines);
333335
// Compute all matches for each one
334336
matchedLines.forEach((line) => {
337+
if (token.isCancellationRequested) {
338+
return;
339+
}
335340
const text = content[line];
336341
const regex = new RegExp(
337342
query.isRegExp ? query.pattern : query.pattern.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"),

0 commit comments

Comments
 (0)