Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSystemWatcher based on RelativePattern does not fire #35171

Closed
kieferrm opened this issue Sep 26, 2017 · 3 comments
Closed

FileSystemWatcher based on RelativePattern does not fire #35171

kieferrm opened this issue Sep 26, 2017 · 3 comments
Labels

Comments

@kieferrm
Copy link
Member

Testing #34831.

  • VSCode Version: Code - Insiders 1.17.0-insider (a5210bc, 2017-09-26T05:11:30.780Z)
  • OS Version: Darwin x64 16.7.0
  • Extensions:
Extension Author (truncated) Version
material-icon-theme PKi 2.2.1
vscode-docker Pet 0.0.18
quokka-vscode Wal 1.0.66
regex chr 0.1.0
crazy kie 0.0.1
githistory don 0.2.3
python don 0.7.0
gitlens eam 5.2.0
tslint eg2 1.0.9
vscode-npm-script eg2 0.2.1
vsc-travis-ci-status fel 1.1.0
svgpreview kis 0.2.0
Go luk 0.6.65
mssql ms- 1.2.0
github-issues-prs ms- 0.5.0
debugger-for-chrome msj 3.3.0
vscode-versionlens pfl 0.19.1
Ruby reb 0.15.0
kustovscode sea 0.0.1
php-syntax-visualizer vsc 0.0.1
vscode-open-in-github ziy 1.2.8

(2 theme extensions excluded)


Steps to Reproduce:

  1. Create an extension with the following code:

The extension uses the following code:

'use strict';
import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

    let watchers: vscode.FileSystemWatcher[] = [];
    let channel = vscode.window.createOutputChannel('relative');
    context.subscriptions.push(channel);

    channel.appendLine(`New output channel`);

    let disposable = vscode.commands.registerCommand('relative.startFileWatchers', () => {
        
        let folders: vscode.WorkspaceFolder[] = vscode.workspace.workspaceFolders;
        let pattern = new vscode.RelativePattern(folders[0], '**/*.ts');
        let watcher = vscode.workspace.createFileSystemWatcher(pattern);
        watcher.onDidChange((event) => { channel.appendLine(`Watcher 1: ${event.fsPath}`); })
        watchers.push(watcher);

        pattern = new vscode.RelativePattern('/Users/kieferrm/Development/test-workspaces/sample', '**/*.ts');
        watcher = vscode.workspace.createFileSystemWatcher(pattern);
        watcher.onDidChange((event) => { channel.appendLine(`Watcher 2: ${event.fsPath}`); })
        watchers.push(watcher);

        watcher = vscode.workspace.createFileSystemWatcher('**/*.ts');
        watcher.onDidChange((event) => { channel.appendLine(`Watcher 3: ${event.fsPath}`); })
        watchers.push(watcher);
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand('relative.stopFileWatchers', () => {
       watchers.forEach(e => e.dispose());
    });
    context.subscriptions.push(disposable);
}

export function deactivate() {
}

package.json:

{
    "name": "relative",
    "displayName": "relative",
    "description": "",
    "version": "0.0.1",
    "publisher": "kieferrm",
    "engines": {
        "vscode": "^1.16.0"
    },
    "categories": [
        "Other"
    ],
    "activationEvents": [
        "onCommand:relative.startFileWatchers"
    ],
    "main": "./out/src/extension",
    "contributes": {
        "commands": [
            {
                "command": "relative.startFileWatchers",
                "title": "Relative: Start File Watchers"
            },
            {
                "command": "relative.stopFileWatchers",
                "title": "Relative: Stop File Watchers"
            }
        ]
    },
    "scripts": {
        "vscode:prepublish": "npm run compile",
        "compile": "tsc -p ./",
        "watch": "tsc -watch -p ./",
        "postinstall": "node ./node_modules/vscode/bin/install"
    },
    "devDependencies": {
        "typescript": "^2.5.2",
        "vscode": "^1.1.5",
        "@types/node": "^7.0.43"
    }
}
  1. Launch extension on a sample workspace containing TS files
  2. Choose Relative: Start File Watchers from the command palette
  3. Switch to relative output channel
  4. Modify a TS file

-> watcher 3 fire. I'd expect all three of them to fire.

@kieferrm
Copy link
Member Author

kieferrm commented Sep 26, 2017

The problem is that the API and the actual implementation differ. The implementation expects the parameters of RelativePattern in opposite sequence.

The issue is in the test description, when using * as vscode engine version. @bpasero already changed made changes since the build was created.

@kieferrm
Copy link
Member Author

When running out of source the extension behaves as expected.

@bpasero
Copy link
Member

bpasero commented Sep 27, 2017

@kieferrm yeah sorry, this is because of #35103

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants