updateWorkspaceFolders method
This method replaces deleteCount
{@link workspace.workspaceFoldersworkspace folders} 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.
Note: in some cases calling this method may result in the currently executing extensions (including the
one that called this method) to be terminated and restarted. For example when the first workspace folder is
added, removed or changed the (deprecated) rootPath
property is updated to point to the first workspace
folder. Another case is when transitioning from an empty or single-folder workspace into a multi-folder
workspace (see also: https://code.visualstudio.com/docs/editor/workspaces).
Use the {@linkcode onDidChangeWorkspaceFoldersonDidChangeWorkspaceFolders()} event to get notified when the workspace folders have been updated.
Example: adding a new workspace folder at the end of workspace folders
workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
Example: removing the first workspace folder
workspace.updateWorkspaceFolders(0, 1);
Example: replacing an existing workspace folder with a new one
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 {@link updateWorkspaceFoldersupdateWorkspaceFolders()} multiple times without waiting for the {@linkcode onDidChangeWorkspaceFoldersonDidChangeWorkspaceFolders()} to fire.
Implementation
_i2.bool updateWorkspaceFolders(
_i2.num start, [
_i2.num? deleteCount,
_i2.Iterable<_i2.dynamic>? workspaceFoldersToAdd,
]) =>
_i4.callMethod(
this,
'updateWorkspaceFolders',
[
start,
deleteCount ?? _i5.undefined,
...?workspaceFoldersToAdd,
],
);