Skip to content

Commit

Permalink
add/removeFolders => add/removeFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Oct 25, 2017
1 parent 4790e47 commit 158d152
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
16 changes: 8 additions & 8 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5199,30 +5199,30 @@ declare module 'vscode' {
export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;

/**
* Adds workspace folders to the currently opened workspace. Will ignore workspace
* folders that are already part of the workspace.
* Adds a workspac folder to the currently opened workspace.
*
* This method will be a no-op if the folder is already part of the workspace.
*
* Note: if this workspace had no folder opened, all extensions will be restarted
* so that the (deprecated) `rootPath` property is updated to point to the first workspace
* folder.
*
* @param folders a list of workspace folders to add.
* @param folder a workspace folder to add.
*/
export function addWorkspaceFolders(folders: { uri: Uri, name?: string }[]): Thenable<void>;
export function addWorkspaceFolder(uri: Uri, name?: string): Thenable<void>;

/**
* Removes workspace folders from the currently opened workspace if they are part of the
* workspace.
* Remove a workspace folder from the currently opened workspace.
*
* This method will be a no-op when called while not having a workspace opened.
*
* Note: if the first workspace folder is removed, all extensions will be restarted
* so that the (deprecated) `rootPath` property is updated to point to the first workspace
* folder.
*
* @param folders a list of [workspace folders](#WorkspaceFolder) to remove.
* @param folder a [workspace folder](#WorkspaceFolder) to remove.
*/
export function removeWorkspaceFolders(folders: WorkspaceFolder[]): Thenable<void>;
export function removeWorkspaceFolder(folder: WorkspaceFolder): Thenable<void>;

/**
* Returns the [workspace folder](#WorkspaceFolder) that contains a given uri.
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
this._proxy.$acceptWorkspaceData(this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace());
}

$addFolders(folders: { uri: URI, name?: string }[]): Thenable<void> {
return this._contextService.addFolders(folders);
$addFolder(uri: URI, name?: string): Thenable<void> {
return this._contextService.addFolders([{ uri, name }]);
}

$removeFolders(folders: URI[]): Thenable<void> {
return this._contextService.removeFolders(folders);
$removeFolder(folder: URI): Thenable<void> {
return this._contextService.removeFolders([folder]);
}

// --- search ---
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ export function createApiFactory(
get workspaceFolders() {
return extHostWorkspace.getWorkspaceFolders();
},
addWorkspaceFolders(folders) {
return extHostWorkspace.addWorkspaceFolders(folders);
addWorkspaceFolder(uri, name) {
return extHostWorkspace.addWorkspaceFolder(uri, name);
},
removeWorkspaceFolders(folders) {
return extHostWorkspace.removeWorkspaceFolders(folders);
removeWorkspaceFolder(folder) {
return extHostWorkspace.removeWorkspaceFolder(folder);
},
onDidChangeWorkspaceFolders: function (listener, thisArgs?, disposables?) {
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ export interface MainThreadWorkspaceShape extends IDisposable {
$startSearch(include: string | IRelativePattern, exclude: string | IRelativePattern, maxResults: number, requestId: number): Thenable<URI[]>;
$cancelSearch(requestId: number): Thenable<boolean>;
$saveAll(includeUntitled?: boolean): Thenable<boolean>;
$addFolders(folders: { uri: URI, name?: string }[]): Thenable<void>;
$removeFolders(folders: URI[]): Thenable<void>;
$addFolder(uri: URI, name?: string): Thenable<void>;
$removeFolder(folder: URI): Thenable<void>;
}

export interface MainThreadFileSystemShape extends IDisposable {
Expand Down
13 changes: 7 additions & 6 deletions src/vs/workbench/api/node/extHostWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
}
}

addWorkspaceFolders(folders: { uri: URI, name?: string }[]): Thenable<void> {
return this._proxy.$addFolders(folders);
addWorkspaceFolder(uri: URI, name?: string): Thenable<void> {
return this._proxy.$addFolder(uri, name);
}

removeWorkspaceFolders(folders: vscode.WorkspaceFolder[]): Thenable<void> {
const existingWorkspaceFolders = this.getWorkspaceFolders();
const folderUrisToRemove = folders.filter(folder => existingWorkspaceFolders.indexOf(folder) >= 0).map(f => f.uri);
removeWorkspaceFolder(folder: vscode.WorkspaceFolder): Thenable<void> {
if (this.getWorkspaceFolders().indexOf(folder) === -1) {
return Promise.resolve(undefined);
}

return this._proxy.$removeFolders(folderUrisToRemove);
return this._proxy.$removeFolder(folder.uri);
}

getWorkspaceFolder(uri: vscode.Uri, resolveParent?: boolean): vscode.WorkspaceFolder {
Expand Down

0 comments on commit 158d152

Please sign in to comment.