mirror of
https://github.com/coder/code-server.git
synced 2026-05-10 06:17:27 +02:00
chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
@@ -6,9 +6,8 @@
|
||||
import * as nls from 'vs/nls';
|
||||
import { isMacintosh, language } from 'vs/base/common/platform';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { app, Menu, MenuItem, BrowserWindow, MenuItemConstructorOptions, WebContents, Event, KeyboardEvent } from 'electron';
|
||||
import { app, Menu, MenuItem, BrowserWindow, MenuItemConstructorOptions, WebContents, KeyboardEvent } from 'electron';
|
||||
import { getTitleBarStyle, INativeRunActionInWindowRequest, INativeRunKeybindingInWindowRequest, IWindowOpenable } from 'vs/platform/windows/common/windows';
|
||||
import { OpenContext } from 'vs/platform/windows/node/window';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IUpdateService, StateType } from 'vs/platform/update/common/update';
|
||||
@@ -16,7 +15,7 @@ import product from 'vs/platform/product/common/product';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { mnemonicMenuLabel } from 'vs/base/common/labels';
|
||||
import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IWindowsMainService, IWindowsCountChangedEvent, OpenContext } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
|
||||
import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction, IMenubarMenu, isMenubarMenuItemUriAction } from 'vs/platform/menubar/common/menubar';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -62,7 +61,7 @@ export class Menubar {
|
||||
|
||||
private keybindings: { [commandId: string]: IMenubarKeybinding };
|
||||
|
||||
private readonly fallbackMenuHandlers: { [id: string]: (menuItem: MenuItem, browserWindow: BrowserWindow | undefined, event: Event) => void } = Object.create(null);
|
||||
private readonly fallbackMenuHandlers: { [id: string]: (menuItem: MenuItem, browserWindow: BrowserWindow | undefined, event: KeyboardEvent) => void } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IUpdateService private readonly updateService: IUpdateService,
|
||||
@@ -608,45 +607,18 @@ export class Menubar {
|
||||
}
|
||||
}
|
||||
|
||||
private static _menuItemIsTriggeredViaKeybinding(event: KeyboardEvent, userSettingsLabel: string): boolean {
|
||||
// The event coming in from Electron will inform us only about the modifier keys pressed.
|
||||
// The strategy here is to check if the modifier keys match those of the keybinding,
|
||||
// since it is highly unlikely to use modifier keys when clicking with the mouse
|
||||
if (!userSettingsLabel) {
|
||||
// There is no keybinding
|
||||
return false;
|
||||
}
|
||||
|
||||
let ctrlRequired = /ctrl/.test(userSettingsLabel);
|
||||
let shiftRequired = /shift/.test(userSettingsLabel);
|
||||
let altRequired = /alt/.test(userSettingsLabel);
|
||||
let metaRequired = /cmd/.test(userSettingsLabel) || /super/.test(userSettingsLabel);
|
||||
|
||||
if (!ctrlRequired && !shiftRequired && !altRequired && !metaRequired) {
|
||||
// This keybinding does not use any modifier keys, so we cannot use this heuristic
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
ctrlRequired === event.ctrlKey
|
||||
&& shiftRequired === event.shiftKey
|
||||
&& altRequired === event.altKey
|
||||
&& metaRequired === event.metaKey
|
||||
);
|
||||
}
|
||||
|
||||
private createMenuItem(label: string, commandId: string | string[], enabled?: boolean, checked?: boolean): MenuItem;
|
||||
private createMenuItem(label: string, click: () => void, enabled?: boolean, checked?: boolean): MenuItem;
|
||||
private createMenuItem(arg1: string, arg2: any, arg3?: boolean, arg4?: boolean): MenuItem {
|
||||
const label = this.mnemonicLabel(arg1);
|
||||
const click: () => void = (typeof arg2 === 'function') ? arg2 : (menuItem: MenuItem & IMenuItemWithKeybinding, win: BrowserWindow, event: Event) => {
|
||||
const click: () => void = (typeof arg2 === 'function') ? arg2 : (menuItem: MenuItem & IMenuItemWithKeybinding, win: BrowserWindow, event: KeyboardEvent) => {
|
||||
const userSettingsLabel = menuItem ? menuItem.userSettingsLabel : null;
|
||||
let commandId = arg2;
|
||||
if (Array.isArray(arg2)) {
|
||||
commandId = this.isOptionClick(event) ? arg2[1] : arg2[0]; // support alternative action if we got multiple action Ids and the option key was pressed while invoking
|
||||
}
|
||||
|
||||
if (userSettingsLabel && Menubar._menuItemIsTriggeredViaKeybinding(event, userSettingsLabel)) {
|
||||
if (userSettingsLabel && event.triggeredByAccelerator) {
|
||||
this.runActionInRenderer({ type: 'keybinding', userSettingsLabel });
|
||||
} else {
|
||||
this.runActionInRenderer({ type: 'commandId', commandId });
|
||||
@@ -706,8 +678,8 @@ export class Menubar {
|
||||
return new MenuItem(this.withKeybinding(commandId, options));
|
||||
}
|
||||
|
||||
private makeContextAwareClickHandler(click: () => void, contextSpecificHandlers: IMenuItemClickHandler): () => void {
|
||||
return () => {
|
||||
private makeContextAwareClickHandler(click: (menuItem: MenuItem, win: BrowserWindow, event: KeyboardEvent) => void, contextSpecificHandlers: IMenuItemClickHandler): (menuItem: MenuItem, win: BrowserWindow | undefined, event: KeyboardEvent) => void {
|
||||
return (menuItem: MenuItem, win: BrowserWindow | undefined, event: KeyboardEvent) => {
|
||||
|
||||
// No Active Window
|
||||
const activeWindow = BrowserWindow.getFocusedWindow();
|
||||
@@ -722,7 +694,7 @@ export class Menubar {
|
||||
}
|
||||
|
||||
// Finally execute command in Window
|
||||
click();
|
||||
click(menuItem, win || activeWindow, event);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user