mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Make workspace folder modification API stable (#44049)
* make API stable * make deleteCount: number | undefined | null
This commit is contained in:
parent
09de75fe5d
commit
f2ffc972c2
43
src/vs/vscode.d.ts
vendored
43
src/vs/vscode.d.ts
vendored
|
@ -5454,6 +5454,49 @@ declare module 'vscode' {
|
|||
*/
|
||||
export function asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string;
|
||||
|
||||
/**
|
||||
* This method replaces `deleteCount` [workspace folders](#workspace.workspaceFolders) starting at index `start`
|
||||
* by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
|
||||
* behavior can be used to add, remove and change workspace folders in a single operation.
|
||||
*
|
||||
* If the first workspace folder is added, removed or changed, the currently executing extensions (including the
|
||||
* one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
|
||||
* updated to point to the first workspace folder.
|
||||
*
|
||||
* Use the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) event to get notified when the
|
||||
* workspace folders have been updated.
|
||||
*
|
||||
* **Example:** adding a new workspace folder at the end of workspace folders
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
|
||||
* ```
|
||||
*
|
||||
* **Example:** removing the first workspace folder
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(0, 1);
|
||||
* ```
|
||||
*
|
||||
* **Example:** replacing an existing workspace folder with a new one
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(0, 1, { uri: ...});
|
||||
* ```
|
||||
*
|
||||
* It is valid to remove an existing workspace folder and add it again with a different name
|
||||
* to rename that folder.
|
||||
*
|
||||
* **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times
|
||||
* without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire.
|
||||
*
|
||||
* @param start the zero-based location in the list of currently opened [workspace folders](#WorkspaceFolder)
|
||||
* from which to start deleting workspace folders.
|
||||
* @param deleteCount the optional number of workspace folders to remove.
|
||||
* @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
|
||||
* Each workspace is identified with a mandatory URI and an optional name.
|
||||
* @return true if the operation was successfully started and false otherwise if arguments were used that would result
|
||||
* in invalid workspace folder state (e.g. 2 folders with the same URI).
|
||||
*/
|
||||
export function updateWorkspaceFolders(start: number, deleteCount: number | undefined | null, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean;
|
||||
|
||||
/**
|
||||
* Creates a file system watcher.
|
||||
*
|
||||
|
|
43
src/vs/vscode.proposed.d.ts
vendored
43
src/vs/vscode.proposed.d.ts
vendored
|
@ -214,49 +214,6 @@ declare module 'vscode' {
|
|||
|
||||
export namespace workspace {
|
||||
export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider): Disposable;
|
||||
|
||||
/**
|
||||
* This method replaces `deleteCount` [workspace folders](#workspace.workspaceFolders) starting at index `start`
|
||||
* by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
|
||||
* behavior can be used to add, remove and change workspace folders in a single operation.
|
||||
*
|
||||
* If the first workspace folder is added, removed or changed, the currently executing extensions (including the
|
||||
* one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
|
||||
* updated to point to the first workspace folder.
|
||||
*
|
||||
* Use the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) event to get notified when the
|
||||
* workspace folders have been updated.
|
||||
*
|
||||
* **Example:** adding a new workspace folder at the end of workspace folders
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
|
||||
* ```
|
||||
*
|
||||
* **Example:** removing the first workspace folder
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(0, 1);
|
||||
* ```
|
||||
*
|
||||
* **Example:** replacing an existing workspace folder with a new one
|
||||
* ```typescript
|
||||
* workspace.updateWorkspaceFolders(0, 1, { uri: ...});
|
||||
* ```
|
||||
*
|
||||
* It is valid to remove an existing workspace folder and add it again with a different name
|
||||
* to rename that folder.
|
||||
*
|
||||
* **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times
|
||||
* without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire.
|
||||
*
|
||||
* @param start the zero-based location in the list of currently opened [workspace folders](#WorkspaceFolder)
|
||||
* from which to start deleting workspace folders.
|
||||
* @param deleteCount the optional number of workspace folders to remove.
|
||||
* @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
|
||||
* Each workspace is identified with a mandatory URI and an optional name.
|
||||
* @return true if the operation was successfully started and false otherwise if arguments were used that would result
|
||||
* in invalid workspace folder state (e.g. 2 folders with the same URI).
|
||||
*/
|
||||
export function updateWorkspaceFolders(start: number, deleteCount: number, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean;
|
||||
}
|
||||
|
||||
export namespace window {
|
||||
|
|
|
@ -433,9 +433,9 @@ export function createApiFactory(
|
|||
set name(value) {
|
||||
throw errors.readonly();
|
||||
},
|
||||
updateWorkspaceFolders: proposedApiFunction(extension, (index, deleteCount, ...workspaceFoldersToAdd) => {
|
||||
return extHostWorkspace.updateWorkspaceFolders(extension, index, deleteCount, ...workspaceFoldersToAdd);
|
||||
}),
|
||||
updateWorkspaceFolders: (index, deleteCount, ...workspaceFoldersToAdd) => {
|
||||
return extHostWorkspace.updateWorkspaceFolders(extension, index, deleteCount || 0, ...workspaceFoldersToAdd);
|
||||
},
|
||||
onDidChangeWorkspaceFolders: function (listener, thisArgs?, disposables?) {
|
||||
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue