microsoft / microsoft/vscode

workspace.createFileSystemWatcher(RelativePattern) prevents renaming the watched directory's parent on Windows

Open
#334,673 0 comments 0 reactions 1 assignee Claimed by @kycutler View on GitHub
stale triage-needed
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

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

- VS Code Version: 1.136.1
- OS Version: Windows 11 x64, build 26200

### Description
Creating a file-system watcher whose `RelativePattern` is rooted in a nested directory prevents renaming that directory's parent on Windows.

Steps to Reproduce:

I have created a minimal reproduction with vscode-extension-samples. See the changes on this branch
https://github.com/dibarbet/vscode-extension-samples/tree/editorconfig-file-watcher-repro/file-watcher-directory-lock-repro
Clone and build the repo, run the file-watcher-directory-lock-repro sample with the F5 Run Extension launch configuration. Attempt to rename folder `b` - it will fail on Windows (have not tried other OS).

Closing the Extension Development Host disposes the watcher and immediately makes `a\b` renamable again.

The extension makes one relevant API call:

```ts
const watchedDirectory = vscode.Uri.joinPath(
workspaceFolder.uri,
'a',
'b',
'c'
);

const watcher = vscode.workspace.createFileSystemWatcher(
new vscode.RelativePattern(watchedDirectory, '.editorconfig')
);
```

The bundled workspace contains:

```text
repro-workspace/
└─ a/
└─ b/
└─ c/
├─ .editorconfig
└─ Test.cs
```

Issue was originally reported at https://github.com/microsoft/vscode-dotnettools/issues/3449

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.