diff options
author | Alex Dima <alexdima@microsoft.com> | 2016-12-09 11:39:46 +0300 |
---|---|---|
committer | Alex Dima <alexdima@microsoft.com> | 2016-12-09 11:42:18 +0300 |
commit | df6fcbe12a000a62fb526fe6953405e28c6e6fc3 (patch) | |
tree | b36487dd5feb752b2943464f8db1151bd4462466 | |
parent | 986607b4bc2d63870b024c913b8fc9117e0bda02 (diff) |
Fixes #16953: Don't depend on vs/nls in the workertranslation/20161209.01
30 files changed, 120 insertions, 128 deletions
diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index b409847ece7..ffb18784c3b 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -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 diff --git a/src/vs/base/browser/keyboardEvent.ts b/src/vs/base/browser/keyboardEvent.ts index d0bf2d2f175..f9dadd7b77d 100644 --- a/src/vs/base/browser/keyboardEvent.ts +++ b/src/vs/base/browser/keyboardEvent.ts @@ -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'; diff --git a/src/vs/base/browser/ui/dropdown/dropdown.ts b/src/vs/base/browser/ui/dropdown/dropdown.ts index 1178d9dfa8e..8717ac76154 100644 --- a/src/vs/base/browser/ui/dropdown/dropdown.ts +++ b/src/vs/base/browser/ui/dropdown/dropdown.ts @@ -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; diff --git a/src/vs/base/browser/ui/menu/menu.ts b/src/vs/base/browser/ui/menu/menu.ts index 6c526ac7e6a..b554e74cdcc 100644 --- a/src/vs/base/browser/ui/menu/menu.ts +++ b/src/vs/base/browser/ui/menu/menu.ts @@ -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; diff --git a/src/vs/base/browser/ui/toolbar/toolbar.ts b/src/vs/base/browser/ui/toolbar/toolbar.ts index 68036a120c9..49553722f2d 100644 --- a/src/vs/base/browser/ui/toolbar/toolbar.ts +++ b/src/vs/base/browser/ui/toolbar/toolbar.ts @@ -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'; diff --git a/src/vs/base/common/keyCodes.ts b/src/vs/base/common/keyCodes.ts index afb8c6e70f9..c8fa0e01247 100644 --- a/src/vs/base/common/keyCodes.ts +++ b/src/vs/base/common/keyCodes.ts @@ -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); + } +} diff --git a/src/vs/base/common/keybinding.ts b/src/vs/base/common/keybinding.ts index 87cbb0fa5c5..157b147ba51 100644 --- a/src/vs/base/common/keybinding.ts +++ b/src/vs/base/common/keybinding.ts @@ -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 { diff --git a/src/vs/base/parts/quickopen/common/quickOpen.ts b/src/vs/base/parts/quickopen/common/quickOpen.ts index cff3c71e2ef..1fceba5dce2 100644 --- a/src/vs/base/parts/quickopen/common/quickOpen.ts +++ b/src/vs/base/parts/quickopen/common/quickOpen.ts @@ -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[]; diff --git a/src/vs/base/parts/tree/browser/treeDefaults.ts b/src/vs/base/parts/tree/browser/treeDefaults.ts index 9b14994be7d..7843d9b349d 100644 --- a/src/vs/base/parts/tree/browser/treeDefaults.ts +++ b/src/vs/base/parts/tree/browser/treeDefaults.ts @@ -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; diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 143485e656b..f92b756404f 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -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) { diff --git a/src/vs/editor/common/standalone/standaloneBase.ts b/src/vs/editor/common/standalone/standaloneBase.ts index f3d1143e4a6..3e169265ae5 100644 --- a/src/vs/editor/common/standalone/standaloneBase.ts +++ b/src/vs/editor/common/standalone/standaloneBase.ts @@ -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'; diff --git a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts index a356d54f71d..326b615d401 100644 --- a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts @@ -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'; diff --git a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts index b8c725f9129..a66f37afa16 100644 --- a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts +++ b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts @@ -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); diff --git a/src/vs/editor/test/browser/standalone/simpleServices.test.ts b/src/vs/editor/test/browser/standalone/simpleServices.test.ts index 3e3917be5c5..d520bfff289 100644 --- a/src/vs/editor/test/browser/standalone/simpleServices.test.ts +++ b/src/vs/editor/test/browser/standalone/simpleServices.test.ts @@ -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', () => { diff --git a/src/vs/editor/test/common/standalone/standaloneBase.test.ts b/src/vs/editor/test/common/standalone/standaloneBase.test.ts index d9915823192..bad680eda7a 100644 --- a/src/vs/editor/test/common/standalone/standaloneBase.test.ts +++ b/src/vs/editor/test/common/standalone/standaloneBase.test.ts @@ -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); } diff --git a/src/vs/platform/contextview/browser/contextView.ts b/src/vs/platform/contextview/browser/contextView.ts index 5474a8429e8..e5819a950e6 100644 --- a/src/vs/platform/contextview/browser/contextView.ts +++ b/src/vs/platform/contextview/browser/contextView.ts @@ -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'); diff --git a/src/vs/platform/keybinding/common/abstractKeybindingService.ts b/src/vs/platform/keybinding/common/abstractKeybindingService.ts index 62c11c974d7..f48da515fe8 100644 --- a/src/vs/platform/keybinding/common/abstractKeybindingService.ts +++ b/src/vs/platform/keybinding/common/abstractKeybindingService.ts @@ -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 { diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index d692030858d..ee9a2204ea1 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -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'; diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index 5c1d6590a5b..0984c895bc0 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -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 { diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index 158cd1060ae..65c49105262 100644 --- a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts @@ -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 = []; diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index 48a53af18d2..65da000d218 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -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 { diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts index 4fba88dacd1..7cee0fd511a 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts @@ -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'; diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index 045f68d3e26..e06058ec951 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -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'; diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index cdeb97162a5..70975873fe8 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -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; } diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 6d9995addab..4428cc1b8ff 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -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'; diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index c2ade6eb9bc..6b5e4903f30 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -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'; diff --git a/src/vs/workbench/parts/markers/browser/markersTreeController.ts b/src/vs/workbench/parts/markers/browser/markersTreeController.ts index eb1ef5ce954..d699a1c77be 100644 --- a/src/vs/workbench/parts/markers/browser/markersTreeController.ts +++ b/src/vs/workbench/parts/markers/browser/markersTreeController.ts @@ -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'; diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index 981d250faa5..722a497ebf7 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -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'; diff --git a/src/vs/workbench/parts/update/electron-browser/update.ts b/src/vs/workbench/parts/update/electron-browser/update.ts index 0dbb59fea8b..e5386bf1609 100644 --- a/src/vs/workbench/parts/update/electron-browser/update.ts +++ b/src/vs/workbench/parts/update/electron-browser/update.ts @@ -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; diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index 6b2b3aff403..c04207e8d22 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -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) |