Skip to content

File System Watcher has double slashes // as path separator #210517

Closed

Description

@BoykoAlex

Version: 1.88.1 (Universal)
Commit: e170252
Date: 2024-04-10T17:42:52.765Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0

Add the following in your extension activation:

        const fileSystemWatcher = workspace.createFileSystemWatcher("**/*", true, false, true);
        fileSystemWatcher.onDidChange(uri => {
            console.log(`Changed file: ${uri.fsPath}`);
        });

Now this prints:

Changed file: /Users/aboyko/git/vscode-spring-boot-dashboard/test/projects/spring-petclinic//src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java
extensionHostProcess.js:146
Changed file: /Users/aboyko/git/vscode-spring-boot-dashboard/test/projects/spring-petclinic//target/classes/org/springframework/samples/petclinic/owner/OwnerController.class

Note the // in both URIs: petclinic//src and petclinic//target

Activity

  1. bpasero commented on Apr 17, 2024

    @bpasero
    Contributor

    I cannot reproduce, you would have to tell me exactly how your setup looks like (folder path you run from, etc.).

    image

    Can you try to reproduce with our nightly insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/

  2. added
    info-needed
    file-watcher
    on Apr 17, 2024
  3. martinlippert commented on Apr 17, 2024

    @martinlippert

    I can reproduce the issue with the latest nightly insiders build as well. No idea yet what exactly triggers this though.
    The didSave event contains the correct URI, whereas the didChangeWatchedFiles event contains a URI with the duplicated / at the position of the folder that I opened.

    In the example above from Alex Boyko (@BoykoAlex) the folder that got opened in VSCode is /Users/aboyko/git/vscode-spring-boot-dashboard/test/projects/spring-petclinic, the src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java is the path inside the project. So it looks to me like the duplicated / shows up between the workspace folder and the path inside the workspace.

  4. bpasero commented on Apr 17, 2024

    @bpasero
    Contributor

    👋 Martin

    I wonder if some other extension installs a watcher that ends up with this double slash. Does it reproduce with all extensions disabled except for the one that creates the watcher?

    Specifically, I would try with disabling the Java extension and friends.

  5. martinlippert commented on Apr 17, 2024

    @martinlippert

    👋 Ben! Long time, no see... :-)

    You are right, once I have this extension active: vscjava.vscode-java-dependency, the events from the file watcher have the double slashes problem. Without that extension active, the events look fine.

  6. bpasero commented on Apr 17, 2024

    @bpasero
    Contributor

    Ok thanks for confirming, we document that baseUri cannot have trailing slashes:

    /**
    * A base file path to which this pattern will be matched against relatively. The
    * file path must be absolute, should not have any trailing path separators and
    * not include any relative segments (`.` or `..`).
    */
    baseUri: Uri;

    I will go ahead and close this issue.

  7. bpasero commented on Apr 17, 2024

    @bpasero
    Contributor

    I am pushing #210561 to have trailing path separators removed from file watch requests. In my testing when I have a watcher with a trailing slash, I am not ending up with double slashes anymore:

    const fileSystemWatcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(`/Users/bpasero/Development/Microsoft/vscode/`, `**`), true, false, true);
    fileSystemWatcher.onDidChange(uri => {
    	console.log(`Changed file: ${uri.fsPath}`);
    });
  8. added
    bug
    confirmed
    and removed
    info-needed
    on Apr 17, 2024
  9. locked and limited conversation to collaborators on Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugconfirmedfile-watcherverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions