mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
very first proposed API for multiple roots, #28526
This commit is contained in:
@@ -54,6 +54,12 @@ export interface IExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof vscode;
|
||||
}
|
||||
|
||||
function assertProposedApi(extension: IExtensionDescription): void {
|
||||
if (!extension.enableProposedApi) {
|
||||
throw new Error(`[${extension.id}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
function proposedApiFunction<T>(extension: IExtensionDescription, fn: T): T {
|
||||
if (extension.enableProposedApi) {
|
||||
return fn;
|
||||
@@ -348,6 +354,13 @@ export function createApiFactory(
|
||||
set rootPath(value) {
|
||||
throw errors.readonly();
|
||||
},
|
||||
get workspaceFolders() {
|
||||
assertProposedApi(extension);
|
||||
return extHostWorkspace.getRoots();
|
||||
},
|
||||
onDidChangeWorkspaceFolders: proposedApiFunction(extension, (listener, thisArgs?, disposables?) => {
|
||||
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
|
||||
}),
|
||||
asRelativePath: (pathOrUri) => {
|
||||
return extHostWorkspace.getRelativePath(pathOrUri);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user