From d5307c5afa4d00360308af47146311e652e4f5ee Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 7 Dec 2023 17:38:11 +0100 Subject: [PATCH] Have `workspace.save` and `workspace.saveAs` methods that return the URI (fix #178713) (#200222) --- extensions/vscode-api-tests/package.json | 1 - .../workbench/api/common/extHost.api.impl.ts | 2 -- .../common/extensionsApiProposals.ts | 1 - src/vscode-dts/vscode.d.ts | 23 ++++++++++++ .../vscode.proposed.saveEditor.d.ts | 35 ------------------- 5 files changed, 23 insertions(+), 39 deletions(-) delete mode 100644 src/vscode-dts/vscode.proposed.saveEditor.d.ts diff --git a/extensions/vscode-api-tests/package.json b/extensions/vscode-api-tests/package.json index 20b69bfc67492..fc973ba654192 100644 --- a/extensions/vscode-api-tests/package.json +++ b/extensions/vscode-api-tests/package.json @@ -34,7 +34,6 @@ "readonlyMessage", "languageStatusText", "resolvers", - "saveEditor", "scmActionButton", "scmSelectedProvider", "scmTextDocument", diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index dedd24fa4bb02..5219bce72fda1 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -933,11 +933,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostWorkspace.findTextInFiles(query, options || {}, callback, extension.identifier, token); }, save: (uri) => { - checkProposedApiEnabled(extension, 'saveEditor'); return extHostWorkspace.save(uri); }, saveAs: (uri) => { - checkProposedApiEnabled(extension, 'saveEditor'); return extHostWorkspace.saveAs(uri); }, saveAll: (includeUntitled?) => { diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 45eb9782709e9..06142a238d176 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -78,7 +78,6 @@ export const allApiProposals = Object.freeze({ quickPickSortByLabel: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickPickSortByLabel.d.ts', readonlyMessage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.readonlyMessage.d.ts', resolvers: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.resolvers.d.ts', - saveEditor: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.saveEditor.d.ts', scmActionButton: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmActionButton.d.ts', scmHistoryProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts', scmSelectedProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts', diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 1c8a513e3f4fb..99a92ece95a58 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -13648,6 +13648,29 @@ declare module 'vscode' { * Event that fires when the current workspace has been trusted. */ export const onDidGrantWorkspaceTrust: Event; + + /** + * Saves the editor identified by the given resource and returns the resulting resource or `undefined` + * if save was not successful or no editor with the given resource was found. + * + * **Note** that an editor with the provided resource must be opened in order to be saved. + * + * @param uri the associated uri for the opened editor to save. + * @returns A thenable that resolves when the save operation has finished. + */ + export function save(uri: Uri): Thenable; + + /** + * Saves the editor identified by the given resource to a new file name as provided by the user and + * returns the resulting resource or `undefined` if save was not successful or cancelled or no editor + * with the given resource was found. + * + * **Note** that an editor with the provided resource must be opened in order to be saved as. + * + * @param uri the associated uri for the opened editor to save as. + * @returns A thenable that resolves when the save-as operation has finished. + */ + export function saveAs(uri: Uri): Thenable; } /** diff --git a/src/vscode-dts/vscode.proposed.saveEditor.d.ts b/src/vscode-dts/vscode.proposed.saveEditor.d.ts deleted file mode 100644 index c9da82d5542ea..0000000000000 --- a/src/vscode-dts/vscode.proposed.saveEditor.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -// https://github.com/microsoft/vscode/issues/178713 - -declare module 'vscode' { - - export namespace workspace { - - /** - * Saves the editor identified by the given resource and returns the resulting resource or `undefined` - * if save was not successful or no editor with the given resource was found. - * - * **Note** that an editor with the provided resource must be opened in order to be saved. - * - * @param uri the associated uri for the opened editor to save. - * @return A thenable that resolves when the save operation has finished. - */ - export function save(uri: Uri): Thenable; - - /** - * Saves the editor identified by the given resource to a new file name as provided by the user and - * returns the resulting resource or `undefined` if save was not successful or cancelled or no editor - * with the given resource was found. - * - * **Note** that an editor with the provided resource must be opened in order to be saved as. - * - * @param uri the associated uri for the opened editor to save as. - * @return A thenable that resolves when the save-as operation has finished. - */ - export function saveAs(uri: Uri): Thenable; - } -}