Skip to content

Commit 218be87

Browse files
committed
Do not reregister watchers on every file change for qltests
During the qltest discovery, we were recreating the watchers for qltests on every file change. This was causing the watchers to be recreated on each change, while there were no functional changes to the watchers themselves. This commit moves the creation of the watchers to the constructor of the QLTestDiscovery class, and removes the creation of the watchers from the discover() method. The behavior should be the same.
1 parent 262744e commit 218be87

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

extensions/ql-vscode/src/query-testing/qltest-discovery.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ export class QLTestDiscovery extends Discovery {
3131
super("QL Test Discovery", extLogger);
3232

3333
this.push(this.watcher.onDidChange(this.handleDidChange, this));
34+
35+
// Watch for changes to any `.ql` or `.qlref` file in any of the QL packs that contain tests.
36+
this.watcher.addWatch(
37+
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/*.{ql,qlref}"),
38+
);
39+
// need to explicitly watch for changes to directories themselves.
40+
this.watcher.addWatch(
41+
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/"),
42+
);
3443
}
3544

3645
/**
@@ -56,15 +65,6 @@ export class QLTestDiscovery extends Discovery {
5665
protected async discover() {
5766
this._testDirectory = await this.discoverTests();
5867

59-
this.watcher.clear();
60-
// Watch for changes to any `.ql` or `.qlref` file in any of the QL packs that contain tests.
61-
this.watcher.addWatch(
62-
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/*.{ql,qlref}"),
63-
);
64-
// need to explicitly watch for changes to directories themselves.
65-
this.watcher.addWatch(
66-
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/"),
67-
);
6868
this._onDidChangeTests.fire(undefined);
6969
}
7070

0 commit comments

Comments
 (0)