Skip to content

Commit d57698b

Browse files
committed
feat: update filetree when watched files are changed to revalidate text
Ensure that if a file is changed, all text files are revalidated against the new filetree
1 parent 7997180 commit d57698b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

packages/server/src/sampleServer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ connection.onDidChangeConfiguration((change) => {
115115
documents.all().forEach(validate);
116116
});
117117

118-
connection.onDidChangeWatchedFiles((change) => {
118+
connection.onDidChangeWatchedFiles((changes) => {
119+
console.log(changes);
120+
fileSystemService.updateFileList();
121+
documents.all().forEach(validate);
122+
119123
// change.changes.forEach((change) => {
120124
// connection.console.log(change.type.toString() + change.uri);
121125
// });

packages/server/src/services/fs.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ import { URI } from 'vscode-uri';
55

66
class FileSystemService {
77
public moduleFileList: string[] = [];
8+
private workspaces: WorkspaceFolder[] = [];
89

910
public registerWorkspaces(workspaces: WorkspaceFolder[]) {
10-
workspaces.forEach((folder) => {
11+
this.workspaces = workspaces;
12+
this.updateFileList();
13+
}
14+
15+
// public init(rootUri: URI): void {
16+
// this.fileList = this.getAllFiles(rootUri);
17+
// }
18+
19+
public updateFileList(): void {
20+
this.moduleFileList = [];
21+
this.workspaces.forEach((folder) => {
1122
const workspacePath = URI.parse(folder.uri).fsPath;
1223
const workspaceFileList = this.getAllFiles(workspacePath);
1324

@@ -17,10 +28,6 @@ class FileSystemService {
1728
});
1829
}
1930

20-
// public init(rootUri: URI): void {
21-
// this.fileList = this.getAllFiles(rootUri);
22-
// }
23-
2431
private getAllFiles(dirPath: string, isRoot = true): string[] {
2532
const files = readdirSync(dirPath);
2633

0 commit comments

Comments
 (0)