From cf149f8a757a05db671267d774e2fdcc7ddcc3c9 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 30 Oct 2017 14:50:01 +0100 Subject: [PATCH] Provide a parameter to bubble up the error while adding/removing workspace folders through API --- .../api/electron-browser/mainThreadFileSystem.ts | 2 +- .../services/workspace/common/workspaceEditing.ts | 8 +++++--- .../services/workspace/node/workspaceEditingService.ts | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts index 1d11279586d..12a40daabfa 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts @@ -45,7 +45,7 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape { } $onDidAddFileSystemRoot(uri: URI): void { - this._workspaceEditingService.addFolders([{ uri }]); + this._workspaceEditingService.addFolders([{ uri }], true); } $onFileSystemChange(handle: number, changes: IFileChange[]): void { diff --git a/src/vs/workbench/services/workspace/common/workspaceEditing.ts b/src/vs/workbench/services/workspace/common/workspaceEditing.ts index a3a94186d56..3e22bf28ba6 100644 --- a/src/vs/workbench/services/workspace/common/workspaceEditing.ts +++ b/src/vs/workbench/services/workspace/common/workspaceEditing.ts @@ -16,14 +16,16 @@ export interface IWorkspaceEditingService { _serviceBrand: ServiceIdentifier; /** - * Add folders to the existing workspace + * Add folders to the existing workspace. + * When `donotNotifyError` is `true`, error will be bubbled up otherwise, the service handles the error with proper message and action */ - addFolders(folders: IWorkspaceFolderCreationData[]): TPromise; + addFolders(folders: IWorkspaceFolderCreationData[], donotNotifyError?: boolean): TPromise; /** * Remove folders from the existing workspace + * When `donotNotifyError` is `true`, error will be bubbled up otherwise, the service handles the error with proper message and action */ - removeFolders(folders: URI[]): TPromise; + removeFolders(folders: URI[], donotNotifyError?: boolean): TPromise; /** * creates a new workspace with the provided folders and opens it. if path is provided diff --git a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts index 9c158438ad9..305f9857492 100644 --- a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts @@ -51,7 +51,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { ) { } - public addFolders(foldersToAdd: IWorkspaceFolderCreationData[]): TPromise { + public addFolders(foldersToAdd: IWorkspaceFolderCreationData[], donotNotifyError: boolean = false): TPromise { const state = this.contextService.getWorkbenchState(); // If we are in no-workspace or single-folder workspace, adding folders has to @@ -71,10 +71,10 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { // Delegate addition of folders to workspace service otherwise return this.contextService.addFolders(foldersToAdd) - .then(() => null, error => this.handleWorkspaceConfigurationEditingError(error)); + .then(() => null, error => donotNotifyError ? TPromise.wrapError(error) : this.handleWorkspaceConfigurationEditingError(error)); } - public removeFolders(foldersToRemove: URI[]): TPromise { + public removeFolders(foldersToRemove: URI[], donotNotifyError: boolean = false): TPromise { // If we are in single-folder state and the opened folder is to be removed, // we close the workspace and enter the empty workspace state for the window. @@ -87,7 +87,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { // Delegate removal of folders to workspace service otherwise return this.contextService.removeFolders(foldersToRemove) - .then(() => null, error => this.handleWorkspaceConfigurationEditingError(error)); + .then(() => null, error => donotNotifyError ? TPromise.wrapError(error) : this.handleWorkspaceConfigurationEditingError(error)); } public createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise {