diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 3b49a1a952401b338aae89a6564e49a3d3580297..acf69746b511fd1fbc8a91f4e7a8cb2d228fe5dd 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -146,7 +146,7 @@ export function createApiFactory( // extension should specify then the `file`-scheme, e.g `{ scheme: 'fooLang', language: 'fooLang' }` // We only inform once, it is not a warning because we just want to raise awareness and because // we cannot say if the extension is doing it right or wrong... - let checkSelector = (function () { + const checkSelector = (function () { let done = (!extension.isUnderDevelopment); function informOnce(selector: vscode.DocumentSelector) { if (!done) { @@ -171,6 +171,24 @@ export function createApiFactory( }; })(); + // Warn when trying to use the vscode.previewHtml command as it does not work properly in all scenarios and + // has security concerns. + const checkCommand = (() => { + let done = !extension.isUnderDevelopment; + const informOnce = () => { + if (!done) { + done = true; + console.warn(`Extension '${extension.id}' uses the 'vscode.previewHtml' command which is deprecated and will be removed. Please update your extension to use the Webview API: https://go.microsoft.com/fwlink/?linkid=2039309`); + } + }; + return (commandId: string) => { + if (commandId === 'vscode.previewHtml') { + informOnce(); + } + return commandId; + }; + })(); + // namespace: commands const commands: typeof vscode.commands = { registerCommand(id: string, command: (...args: any[]) => T | Thenable, thisArgs?: any): vscode.Disposable { @@ -210,7 +228,7 @@ export function createApiFactory( }); }), executeCommand(id: string, ...args: any[]): Thenable { - return extHostCommands.executeCommand(id, ...args); + return extHostCommands.executeCommand(checkCommand(id), ...args); }, getCommands(filterInternal: boolean = false): Thenable { return extHostCommands.getCommands(filterInternal);