Skip to content

Commit a71be50

Browse files
committed
Fix pattern matching when overriding exclusion/inclusion
1 parent 118173a commit a71be50

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/utilities/filesystem.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import { all, any } from "micromatch";
15+
import { contains } from "micromatch";
1616
import * as fs from "fs/promises";
1717
import * as path from "path";
1818
import * as vscode from "vscode";
@@ -111,17 +111,24 @@ export function isIncluded(
111111
uri: vscode.Uri,
112112
excludeList: Record<string, boolean> = getDefaultExcludeList()
113113
): boolean {
114-
const { include, exclude } = getGlobPattern(excludeList);
115-
const notExcluded = all(
116-
uri.fsPath,
117-
exclude.map(pattern => `!${pattern}`),
118-
{ contains: true }
119-
);
114+
let notExcluded = true;
115+
let included = false;
116+
for (const key of Object.keys(excludeList)) {
117+
if (excludeList[key]) {
118+
if (contains(uri.fsPath, key, { contains: true })) {
119+
notExcluded = false;
120+
included = false;
121+
}
122+
} else {
123+
if (contains(uri.fsPath, key, { contains: true })) {
124+
included = true;
125+
}
126+
}
127+
}
120128
if (notExcluded) {
121129
return true;
122130
}
123-
const reincluded = any(uri.fsPath, include, { contains: true });
124-
return reincluded;
131+
return included;
125132
}
126133

127134
export function isExcluded(

0 commit comments

Comments
 (0)