提交 df6fcbe1 编写于 作者: A Alex Dima

Fixes #16953: Don't depend on vs/nls in the worker

上级 986607b4
......@@ -40,7 +40,7 @@ declare module monaco {
#include(vs/base/common/cancellation): CancellationTokenSource, CancellationToken
#include(vs/base/common/uri): URI
#include(vs/editor/common/standalone/standaloneBase): KeyCode, KeyMod
#include(vs/base/common/keybinding): Keybinding
#include(vs/base/common/keyCodes): Keybinding
#include(vs/base/common/htmlContent): MarkedString
#include(vs/base/browser/keyboardEvent): IKeyboardEvent
#include(vs/base/browser/mouseEvent): IMouseEvent
......
......@@ -5,8 +5,7 @@
'use strict';
import { KeyCode, KeyCodeUtils, KeyMod } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyCodeUtils, KeyMod } from 'vs/base/common/keyCodes';
import * as platform from 'vs/base/common/platform';
import * as browser from 'vs/base/browser/browser';
......
......@@ -15,7 +15,7 @@ import { EventEmitter } from 'vs/base/common/eventEmitter';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { IMenuOptions } from 'vs/base/browser/ui/menu/menu';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
export interface ILabelRenderer {
(container: HTMLElement): IDisposable;
......
......@@ -11,7 +11,7 @@ import { $ } from 'vs/base/browser/builder';
import { IActionRunner, IAction } from 'vs/base/common/actions';
import { ActionBar, IActionItemProvider, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { EventEmitter } from 'vs/base/common/eventEmitter';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
export interface IMenuOptions {
context?: any;
......
......@@ -14,7 +14,7 @@ import types = require('vs/base/common/types');
import { Action, IActionRunner, IAction } from 'vs/base/common/actions';
import { ActionBar, ActionsOrientation, IActionItemProvider, BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextMenuProvider, DropdownMenu, IActionProvider, ILabelRenderer, IDropdownMenuOptions } from 'vs/base/browser/ui/dropdown/dropdown';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
export const CONTEXT = 'context.toolbar';
......
......@@ -477,3 +477,40 @@ export class BinaryKeybindings {
return (keybinding & BinaryKeybindingsMask.KeyCode);
}
}
export class Keybinding {
public value: number;
constructor(keybinding: number) {
this.value = keybinding;
}
public equals(other: Keybinding): boolean {
return this.value === other.value;
}
public hasCtrlCmd(): boolean {
return BinaryKeybindings.hasCtrlCmd(this.value);
}
public hasShift(): boolean {
return BinaryKeybindings.hasShift(this.value);
}
public hasAlt(): boolean {
return BinaryKeybindings.hasAlt(this.value);
}
public hasWinCtrl(): boolean {
return BinaryKeybindings.hasWinCtrl(this.value);
}
public isModifierKey(): boolean {
return BinaryKeybindings.isModifierKey(this.value);
}
public getKeyCode(): KeyCode {
return BinaryKeybindings.extractKeyCode(this.value);
}
}
......@@ -8,14 +8,14 @@
import * as nls from 'vs/nls';
import * as defaultPlatform from 'vs/base/common/platform';
import { IHTMLContentElement } from 'vs/base/common/htmlContent';
import { KeyCode, KeyMod, KeyChord, KeyCodeUtils, BinaryKeybindings, USER_SETTINGS } from 'vs/base/common/keyCodes';
import { Keybinding, KeyCode, KeyMod, KeyChord, KeyCodeUtils, BinaryKeybindings, USER_SETTINGS } from 'vs/base/common/keyCodes';
export interface ISimplifiedPlatform {
isMacintosh: boolean;
isWindows: boolean;
}
export class Keybinding {
export class KeybindingLabels {
private static _cachedKeybindingRegex: string = null;
......@@ -117,7 +117,7 @@ export class Keybinding {
let firstSpaceIdx = input.indexOf(' ');
if (firstSpaceIdx > 0) {
key = input.substring(0, firstSpaceIdx);
chord = Keybinding.fromUserSettingsLabel(input.substring(firstSpaceIdx), Platform);
chord = KeybindingLabels.fromUserSettingsLabel(input.substring(firstSpaceIdx), Platform);
} else {
key = input;
}
......@@ -141,78 +141,44 @@ export class Keybinding {
return KeyChord(result, chord);
}
public value: number;
constructor(keybinding: number) {
this.value = keybinding;
}
public equals(other: Keybinding): boolean {
return this.value === other.value;
}
public hasCtrlCmd(): boolean {
return BinaryKeybindings.hasCtrlCmd(this.value);
}
public hasShift(): boolean {
return BinaryKeybindings.hasShift(this.value);
}
public hasAlt(): boolean {
return BinaryKeybindings.hasAlt(this.value);
}
public hasWinCtrl(): boolean {
return BinaryKeybindings.hasWinCtrl(this.value);
}
public isModifierKey(): boolean {
return BinaryKeybindings.isModifierKey(this.value);
}
public getKeyCode(): KeyCode {
return BinaryKeybindings.extractKeyCode(this.value);
}
/**
* Format the binding to a format appropiate for rendering in the UI
* @internal
*/
public _toUSLabel(Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(this.value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
public static _toUSLabel(keybinding: Keybinding, Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(keybinding.value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
}
/**
* Format the binding to a format appropiate for placing in an aria-label.
* @internal
*/
public _toUSAriaLabel(Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(this.value, AriaKeyLabelProvider.INSTANCE, Platform);
public static _toUSAriaLabel(keybinding: Keybinding, Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(keybinding.value, AriaKeyLabelProvider.INSTANCE, Platform);
}
/**
* Format the binding to a format appropiate for rendering in the UI
* @internal
*/
public _toUSHTMLLabel(Platform: ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
return _asHTML(this.value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
public static _toUSHTMLLabel(keybinding: Keybinding, Platform: ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
return _asHTML(keybinding.value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
}
/**
* Format the binding to a format appropiate for rendering in the UI
* @internal
*/
public toCustomLabel(labelProvider: IKeyBindingLabelProvider, Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(this.value, labelProvider, Platform);
public static toCustomLabel(keybinding: Keybinding, labelProvider: IKeyBindingLabelProvider, Platform: ISimplifiedPlatform = defaultPlatform): string {
return _asString(keybinding.value, labelProvider, Platform);
}
/**
* Format the binding to a format appropiate for rendering in the UI
* @internal
*/
public toCustomHTMLLabel(labelProvider: IKeyBindingLabelProvider, Platform: ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
return _asHTML(this.value, labelProvider, Platform);
public static toCustomHTMLLabel(keybinding: Keybinding, labelProvider: IKeyBindingLabelProvider, Platform: ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
return _asHTML(keybinding.value, labelProvider, Platform);
}
/**
......@@ -220,27 +186,18 @@ export class Keybinding {
* See https://github.com/electron/electron/blob/master/docs/api/accelerator.md
* @internal
*/
public _toElectronAccelerator(Platform: ISimplifiedPlatform = defaultPlatform): string {
if (BinaryKeybindings.hasChord(this.value)) {
public static _toElectronAccelerator(keybinding: Keybinding, Platform: ISimplifiedPlatform = defaultPlatform): string {
if (BinaryKeybindings.hasChord(keybinding.value)) {
// Electron cannot handle chords
return null;
}
let keyCode = BinaryKeybindings.extractKeyCode(this.value);
let keyCode = BinaryKeybindings.extractKeyCode(keybinding.value);
if (keyCode >= KeyCode.NUMPAD_0 && keyCode <= KeyCode.NUMPAD_DIVIDE) {
// Electron cannot handle numpad keys
return null;
}
return _asString(this.value, ElectronAcceleratorLabelProvider.INSTANCE, Platform);
}
/**
* Format the binding to a format appropiate for the user settings file.
* @internal
*/
public toUserSettingsLabel(Platform: ISimplifiedPlatform = defaultPlatform): string {
return Keybinding.toUserSettingsLabel(this.value, Platform);
return _asString(keybinding.value, ElectronAcceleratorLabelProvider.INSTANCE, Platform);
}
}
export interface IKeyBindingLabelProvider {
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
export interface IQuickNavigateConfiguration {
keybindings: Keybinding[];
......
......@@ -14,8 +14,7 @@ import dom = require('vs/base/browser/dom');
import mouse = require('vs/base/browser/mouseEvent');
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import _ = require('vs/base/parts/tree/browser/tree');
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
export interface ILegacyTemplateData {
root: HTMLElement;
......
......@@ -17,7 +17,8 @@ import { IStorageService } from 'vs/code/electron-main/storage';
import { IFilesConfiguration, AutoSaveConfiguration } from 'vs/platform/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IUpdateService, State as UpdateState } from 'vs/platform/update/common/update';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import product from 'vs/platform/product';
import { RunOnceScheduler } from 'vs/base/common/async';
......@@ -119,7 +120,7 @@ export class VSCodeMenu {
// Fill hash map of resolved keybindings
let needsMenuUpdate = false;
keybindings.forEach(keybinding => {
const accelerator = new Keybinding(keybinding.binding)._toElectronAccelerator();
const accelerator = KeybindingLabels._toElectronAccelerator(new Keybinding(keybinding.binding));
if (accelerator) {
this.mapResolvedKeybindingToActionId[keybinding.id] = accelerator;
if (this.mapLastKnownKeybindingToActionId[keybinding.id] !== accelerator) {
......
......@@ -5,8 +5,7 @@
'use strict';
import { Emitter } from 'vs/base/common/event';
import { KeyMod as ConstKeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyMod as ConstKeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { Selection, SelectionDirection } from 'vs/editor/common/core/selection';
......
......@@ -6,8 +6,7 @@
import * as nls from 'vs/nls';
import { IAction } from 'vs/base/common/actions';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import * as dom from 'vs/base/browser/dom';
......
......@@ -9,8 +9,8 @@ import 'vs/css!./defineKeybinding';
import * as nls from 'vs/nls';
import { RunOnceScheduler } from 'vs/base/common/async';
import { MarkedString } from 'vs/base/common/htmlContent';
import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as dom from 'vs/base/browser/dom';
import { renderHtml } from 'vs/base/browser/htmlContentRenderer';
......@@ -148,7 +148,7 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
private _dec: string[] = [];
private _updateDecorationsNow(): void {
let model = this._editor.getModel();
let regex = Keybinding.getUserSettingsKeybindingRegex();
let regex = KeybindingLabels.getUserSettingsKeybindingRegex();
var m = model.findMatches(regex, false, true, false, false);
......@@ -165,7 +165,7 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
return {
strKeybinding: strKeybinding,
keybinding: keybinding,
usLabel: keybinding._toUSLabel(),
usLabel: KeybindingLabels._toUSLabel(keybinding),
label: this._keybindingService.getLabelFor(keybinding),
range: range
};
......@@ -356,7 +356,7 @@ class DefineKeybindingWidget implements IOverlayWidget {
switch (kb.value) {
case KeyCode.Enter:
if (this._lastKeybinding) {
this._onAccepted(this._lastKeybinding.toUserSettingsLabel());
this._onAccepted(KeybindingLabels.toUserSettingsLabel(this._lastKeybinding.value));
}
this._stop();
return;
......@@ -368,7 +368,7 @@ class DefineKeybindingWidget implements IOverlayWidget {
this._lastKeybinding = kb;
this._inputNode.value = this._lastKeybinding.toUserSettingsLabel().toLowerCase();
this._inputNode.value = KeybindingLabels.toUserSettingsLabel(this._lastKeybinding.value).toLowerCase();
this._inputNode.title = 'keyCode: ' + keyEvent.browserEvent.keyCode;
dom.clearNode(this._outputNode);
......
......@@ -9,8 +9,7 @@ import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyServ
import { SimpleConfigurationService, SimpleMessageService, SimpleExtensionService, StandaloneKeybindingService, StandaloneCommandService } from 'vs/editor/browser/standalone/simpleServices';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { KeyCode } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
suite('StandaloneKeybindingService', () => {
......
......@@ -7,7 +7,7 @@
import * as assert from 'assert';
import { KeyCode as StandaloneKeyCode, Severity as StandaloneSeverity } from 'vs/editor/common/standalone/standaloneBase';
import { KeyCode as RuntimeKeyCode } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import RuntimeSeverity from 'vs/base/common/severity';
suite('StandaloneBase', () => {
......@@ -139,7 +139,7 @@ suite('KeyCode', () => {
});
test('getUserSettingsKeybindingRegex', () => {
let regex = new RegExp(Keybinding.getUserSettingsKeybindingRegex());
let regex = new RegExp(KeybindingLabels.getUserSettingsKeybindingRegex());
function testIsGood(userSettingsLabel: string, message: string = userSettingsLabel): void {
let userSettings = '"' + userSettingsLabel.replace(/\\/g, '\\\\') + '"';
......@@ -157,7 +157,7 @@ suite('KeyCode', () => {
if (ignore[keyCode]) {
continue;
}
let userSettings = Keybinding.toUserSettingsLabel(keyCode);
let userSettings = KeybindingLabels.toUserSettingsLabel(keyCode);
testIsGood(userSettings, keyCode + ' - ' + StandaloneKeyCode[keyCode] + ' - ' + userSettings);
}
......
......@@ -8,7 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { IAction } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { TPromise } from 'vs/base/common/winjs.base';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const IContextViewService = createDecorator<IContextViewService>('contextViewService');
......
......@@ -6,7 +6,8 @@
import * as nls from 'vs/nls';
import { IHTMLContentElement } from 'vs/base/common/htmlContent';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Severity from 'vs/base/common/severity';
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
......@@ -60,19 +61,19 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
}
public getLabelFor(keybinding: Keybinding): string {
return keybinding._toUSLabel();
return KeybindingLabels._toUSLabel(keybinding);
}
public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] {
return keybinding._toUSHTMLLabel();
return KeybindingLabels._toUSHTMLLabel(keybinding);
}
public getAriaLabelFor(keybinding: Keybinding): string {
return keybinding._toUSAriaLabel();
return KeybindingLabels._toUSAriaLabel(keybinding);
}
public getElectronAcceleratorFor(keybinding: Keybinding): string {
return keybinding._toElectronAccelerator();
return KeybindingLabels._toElectronAccelerator(keybinding);
}
public getDefaultKeybindings(): string {
......
......@@ -5,7 +5,7 @@
'use strict';
import { IHTMLContentElement } from 'vs/base/common/htmlContent';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ContextKeyExpr, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
import { IResolveResult } from 'vs/platform/keybinding/common/keybindingResolver';
......
......@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { BinaryKeybindings } from 'vs/base/common/keyCodes';
import { ISimplifiedPlatform, Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, BinaryKeybindings } from 'vs/base/common/keyCodes';
import { ISimplifiedPlatform, KeybindingLabels } from 'vs/base/common/keybinding';
import * as platform from 'vs/base/common/platform';
import { IKeybindingItem, IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
......@@ -192,7 +192,7 @@ export class KeybindingResolver {
if (KeybindingResolver.whenIsEntirelyIncluded(true, conflict.when, item.when)) {
// `item` completely overwrites `conflict`
if (this._shouldWarnOnConflict && item.isDefault) {
console.warn('Conflict detected, command `' + conflict.commandId + '` cannot be triggered by ' + Keybinding.toUserSettingsLabel(keypress) + ' due to ' + item.command);
console.warn('Conflict detected, command `' + conflict.commandId + '` cannot be triggered by ' + KeybindingLabels.toUserSettingsLabel(keypress) + ' due to ' + item.command);
}
this._lookupMapUnreachable[conflict.commandId] = this._lookupMapUnreachable[conflict.commandId] || [];
this._lookupMapUnreachable[conflict.commandId].push(conflict.keybinding);
......@@ -447,11 +447,11 @@ export class IOSupport {
}
public static writeKeybinding(input: number, Platform: ISimplifiedPlatform = platform): string {
return Keybinding.toUserSettingsLabel(input, Platform);
return KeybindingLabels.toUserSettingsLabel(input, Platform);
}
public static readKeybinding(input: string, Platform: ISimplifiedPlatform = platform): number {
return Keybinding.fromUserSettingsLabel(input, Platform);
return KeybindingLabels.fromUserSettingsLabel(input, Platform);
}
public static readKeybindingWhen(input: string): ContextKeyExpr {
......
......@@ -5,9 +5,9 @@
'use strict';
import * as assert from 'assert';
import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { Keybinding, KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
import { Keybinding } from 'vs/base/common/keybinding';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import { IDisposable } from 'vs/base/common/lifecycle';
import Severity from 'vs/base/common/severity';
import { ICommandService } from 'vs/platform/commands/common/commands';
......@@ -147,7 +147,7 @@ suite('AbstractKeybindingService', () => {
assert.deepEqual(executeCommandCalls, []);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, [
`(${new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K)._toUSLabel()}) was pressed. Waiting for second key of chord...`
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
assert.deepEqual(statusMessageCallsDisposed, []);
executeCommandCalls = [];
......@@ -161,10 +161,10 @@ suite('AbstractKeybindingService', () => {
assert.deepEqual(executeCommandCalls, []);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, [
`The key combination (${new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K)._toUSLabel()}, ${new Keybinding(KeyCode.Backspace)._toUSLabel()}) is not a command.`
`The key combination (${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}, ${KeybindingLabels._toUSLabel(new Keybinding(KeyCode.Backspace))}) is not a command.`
]);
assert.deepEqual(statusMessageCallsDisposed, [
`(${new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K)._toUSLabel()}) was pressed. Waiting for second key of chord...`
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
executeCommandCalls = [];
showMessageCalls = [];
......@@ -262,7 +262,7 @@ suite('AbstractKeybindingService', () => {
assert.deepEqual(executeCommandCalls, []);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, [
`(${new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K)._toUSLabel()}) was pressed. Waiting for second key of chord...`
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
assert.deepEqual(statusMessageCallsDisposed, []);
executeCommandCalls = [];
......@@ -281,7 +281,7 @@ suite('AbstractKeybindingService', () => {
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, []);
assert.deepEqual(statusMessageCallsDisposed, [
`(${new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K)._toUSLabel()}) was pressed. Waiting for second key of chord...`
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
executeCommandCalls = [];
showMessageCalls = [];
......
......@@ -5,7 +5,8 @@
'use strict';
import { IHTMLContentElement } from 'vs/base/common/htmlContent';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import Event from 'vs/base/common/event';
import { IKeybindingService, IKeybindingEvent } from 'vs/platform/keybinding/common/keybinding';
import { IContextKey, IContextKeyService, IContextKeyServiceTarget, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
......@@ -68,19 +69,19 @@ export class MockKeybindingService2 implements IKeybindingService {
}
public getLabelFor(keybinding: Keybinding): string {
return keybinding._toUSLabel();
return KeybindingLabels._toUSLabel(keybinding);
}
public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] {
return keybinding._toUSHTMLLabel();
return KeybindingLabels._toUSHTMLLabel(keybinding);
}
public getAriaLabelFor(keybinding: Keybinding): string {
return keybinding._toUSAriaLabel();
return KeybindingLabels._toUSAriaLabel(keybinding);
}
public getElectronAcceleratorFor(keybinding: Keybinding): string {
return keybinding._toElectronAccelerator();
return KeybindingLabels._toElectronAccelerator(keybinding);
}
public getDefaultKeybindings(): string {
......
......@@ -22,7 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { dispose } from 'vs/base/common/lifecycle';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { IViewletService, } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
......
......@@ -31,7 +31,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { CloseEditorsInGroupAction, SplitEditorAction, CloseEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, CloseRightEditorsInGroupAction, ShowEditorsInGroupAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
......
......@@ -37,7 +37,8 @@ import product from 'vs/platform/product';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { CombinedInstallAction, UpdateAction, EnableAction, DisableAction, BuiltinStatusLabelAction, ReloadAction } from 'vs/workbench/parts/extensions/browser/extensionsActions';
import WebView from 'vs/workbench/parts/html/browser/webview';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { IMessageService } from 'vs/platform/message/common/message';
......@@ -659,7 +660,7 @@ export class ExtensionEditor extends BaseEditor {
case 'darwin': key = rawKeyBinding.mac; break;
}
const keyBinding = new Keybinding(Keybinding.fromUserSettingsLabel(key || rawKeyBinding.key));
const keyBinding = new Keybinding(KeybindingLabels.fromUserSettingsLabel(key || rawKeyBinding.key));
const result = this.keybindingService.getLabelFor(keyBinding);
return result === 'unknown' ? null : result;
}
......
......@@ -46,8 +46,7 @@ import { IEventService } from 'vs/platform/event/common/event';
import { IInstantiationService, IConstructorSignature2 } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService, IMessageWithAction, IConfirmation, Severity, CancelAction } from 'vs/platform/message/common/message';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { Selection } from 'vs/editor/common/core/selection';
import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
......
......@@ -46,8 +46,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IMessageService, IConfirmation, Severity } from 'vs/platform/message/common/message';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IMenuService, IMenu, MenuId } from 'vs/platform/actions/common/actions';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
......
......@@ -18,7 +18,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService, IMenu, MenuId } from 'vs/platform/actions/common/actions';
import { IAction } from 'vs/base/common/actions';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { IActionProvider } from 'vs/base/parts/tree/browser/actionsRenderer';
import { ActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
......
......@@ -21,8 +21,7 @@ import { CollapseAllAction as TreeCollapseAction } from 'vs/base/parts/tree/brow
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { asFileEditorInput } from 'vs/workbench/common/editor';
......
......@@ -19,7 +19,8 @@ import { ReleaseNotesInput } from 'vs/workbench/parts/update/electron-browser/re
import { IRequestService } from 'vs/platform/request/node/request';
import { asText } from 'vs/base/node/request';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
......@@ -70,7 +71,7 @@ export function loadReleaseNotes(accessor: ServicesAccessor, version: string): T
};
const kbstyle = (match: string, kb: string) => {
const code = Keybinding.fromUserSettingsLabel(kb);
const code = KeybindingLabels.fromUserSettingsLabel(kb);
if (!code) {
return unassigned;
......
......@@ -7,7 +7,8 @@
import * as nls from 'vs/nls';
import { IHTMLContentElement } from 'vs/base/common/htmlContent';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { Keybinding } from 'vs/base/common/keybinding';
import { Keybinding } from 'vs/base/common/keyCodes';
import { KeybindingLabels } from 'vs/base/common/keybinding';
import * as platform from 'vs/base/common/platform';
import { toDisposable } from 'vs/base/common/lifecycle';
import { ExtensionMessageCollector, ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
......@@ -207,15 +208,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}
public getLabelFor(keybinding: Keybinding): string {
return keybinding.toCustomLabel(getNativeLabelProvider());
return KeybindingLabels.toCustomLabel(keybinding, getNativeLabelProvider());
}
public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] {
return keybinding.toCustomHTMLLabel(getNativeLabelProvider());
return KeybindingLabels.toCustomHTMLLabel(keybinding, getNativeLabelProvider());
}
public getAriaLabelFor(keybinding: Keybinding): string {
return keybinding.toCustomLabel(getNativeAriaLabelProvider());
return KeybindingLabels.toCustomLabel(keybinding, getNativeAriaLabelProvider());
}
public getElectronAcceleratorFor(keybinding: Keybinding): string {
......@@ -224,7 +225,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return super.getElectronAcceleratorFor(keybinding);
}
let usLabel = keybinding._toUSLabel();
let usLabel = KeybindingLabels._toUSLabel(keybinding);
let label = this.getLabelFor(keybinding);
if (usLabel !== label) {
// electron menus are incorrect in rendering (linux) and in rendering and interpreting (mac)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册