Reputation: 45
I was looking through the vscode api, and I was wondering if there exists a type of listener event that sees that a file was created in the current workspace folder.
Thank you!
Upvotes: 2
Views: 1327
Reputation: 34148
You can use a FileSystemWatcher
for this, for instance if you wanted to know about the creation of .txt
files in the current workspace:
let folders = vscode.workspace.workspaceFolders;
if (folders) {
let watcher = vscode.workspace.createFileSystemWatcher(
new vscode.RelativePattern(folders[0], "*.txt"));
watcher.onDidCreate(uri => console.log(`created ${uri}`));
}
Upvotes: 4