Update to VS Code 1.52.1

This commit is contained in:
Asher
2021-02-09 16:08:37 +00:00
1351 changed files with 56560 additions and 38990 deletions

View File

@@ -11,6 +11,14 @@ import { IWebviewPortMapping } from 'vs/platform/webview/common/webviewPortMappi
export const IWebviewManagerService = createDecorator<IWebviewManagerService>('webviewManagerService');
export interface WebviewWebContentsId {
readonly webContentsId: number;
}
export interface WebviewWindowId {
readonly windowId: number;
}
export interface IWebviewManagerService {
_serviceBrand: unknown;
@@ -20,7 +28,7 @@ export interface IWebviewManagerService {
didLoadResource(requestId: number, content: VSBuffer | undefined): void;
setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise<void>;
setIgnoreMenuShortcuts(id: WebviewWebContentsId | WebviewWindowId, enabled: boolean): Promise<void>;
}
export interface RegisterWebviewMetadata {

View File

@@ -3,14 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { webContents } from 'electron';
import { WebContents, webContents } from 'electron';
import { VSBuffer } from 'vs/base/common/buffer';
import { Disposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IFileService } from 'vs/platform/files/common/files';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { IRequestService } from 'vs/platform/request/common/request';
import { IWebviewManagerService, RegisterWebviewMetadata } from 'vs/platform/webview/common/webviewManagerService';
import { IWebviewManagerService, RegisterWebviewMetadata, WebviewWebContentsId, WebviewWindowId } from 'vs/platform/webview/common/webviewManagerService';
import { WebviewPortMappingProvider } from 'vs/platform/webview/electron-main/webviewPortMappingProvider';
import { WebviewProtocolProvider } from 'vs/platform/webview/electron-main/webviewProtocolProvider';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
@@ -26,7 +26,7 @@ export class WebviewMainService extends Disposable implements IWebviewManagerSer
@IFileService fileService: IFileService,
@IRequestService requestService: IRequestService,
@ITunnelService tunnelService: ITunnelService,
@IWindowsMainService windowsMainService: IWindowsMainService,
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
) {
super();
this.protocolProvider = this._register(new WebviewProtocolProvider(fileService, requestService, windowsMainService));
@@ -70,11 +70,24 @@ export class WebviewMainService extends Disposable implements IWebviewManagerSer
});
}
public async setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise<void> {
const contents = webContents.fromId(webContentsId);
if (!contents) {
throw new Error(`Invalid webContentsId: ${webContentsId}`);
public async setIgnoreMenuShortcuts(id: WebviewWebContentsId | WebviewWindowId, enabled: boolean): Promise<void> {
let contents: WebContents | undefined;
if (typeof (id as WebviewWindowId).windowId === 'number') {
const { windowId } = (id as WebviewWindowId);
const window = this.windowsMainService.getWindowById(windowId);
if (!window) {
throw new Error(`Invalid windowId: ${windowId}`);
}
contents = window.win.webContents;
} else {
const { webContentsId } = (id as WebviewWebContentsId);
contents = webContents.fromId(webContentsId);
if (!contents) {
throw new Error(`Invalid webContentsId: ${webContentsId}`);
}
}
if (!contents.isDestroyed()) {
contents.setIgnoreMenuShortcuts(enabled);
}