Skip to content

FileSystemWatcher fires 2 onCreate and 2 onDelete events #303179

@rioj7

Description

@rioj7

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.111.0
  • OS Version: Windows 11

Steps to Reproduce:

  1. Create a VSCode extension with the following JavaScript code:
    function activate(context) {
      let seqnum = 1;
      const path = vscode.workspace.workspaceFolders[0].uri.fsPath;
      const toWatch = new vscode.RelativePattern(vscode.Uri.file(path), '.vscode/foobar.txt');
      const watcher = vscode.workspace.createFileSystemWatcher(toWatch, false, true, false);
      context.subscriptions.push(watcher.onDidCreate(uri => { console.log(seqnum, 'onCreate', uri.fsPath); seqnum += 1; }));
      context.subscriptions.push(watcher.onDidDelete(uri => { console.log(seqnum, 'onDelete', uri.fsPath); seqnum += 1; }));
    }
    function deactivate() {
    }
    
    module.exports = {
      activate,
      deactivate
    }
  2. Launch this extension in debug mode
  3. Make sure a Workspace Folder is opened on Launch
  4. With the OS File manager or from terminal create the file <workspace>/.vscode/foobar.txt
  5. With the OS File manager or from terminal delete the file <workspace>/.vscode/foobar.txt
  6. Look in de Debug Console of the VSCode that launched the extension.
    1 onCreate <workspace>\.vscode\foobar.txt
    2 onCreate <workspace>\.vscode\foobar.txt
    3 onDelete <workspace>\.vscode\foobar.txt
    4 onDelete <workspace>\.vscode\foobar.txt
    
  7. The onCreate and onDelete events are received twice.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions