vscode#WorkspaceFoldersChangeEvent TypeScript Examples

The following examples show how to use vscode#WorkspaceFoldersChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkspaceManager.ts    From al-objid with MIT License 6 votes vote down vote up
private onDidChangeWorkspaceFolders({ added, removed }: WorkspaceFoldersChangeEvent) {
        // Remove any ALApp instances that are no longer in workspace
        const alRemoved: ALApp[] = [];
        this._apps = this._apps.filter(app => {
            const stillExists = !removed.find(folder => app.isFolder(folder));
            if (!stillExists) {
                alRemoved.push(app);
                delete this._appMap[app.uri.fsPath];
                delete this._appHashMap[app.hash];
            }
            return stillExists;
        });
        this._folders = this._folders.filter(
            oldFolder => !removed.find(removedFolder => removedFolder.uri.fsPath === oldFolder.uri.fsPath)
        );

        // Add any folders that are added to the workspace
        const alAdded: ALApp[] = [];
        this.addFoldersToWatch(added as WorkspaceFolder[], alAdded);

        // Fire the event with any AL Apps added or removed
        if (alRemoved.length || alAdded.length) {
            this._onDidChangeALFolders.fire({ added: alAdded, removed: alRemoved });
        }

        // Dispose of removed apps
        for (let app of alRemoved) {
            app.dispose();
        }
    }