Vscode merge (#4582)

* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
This commit is contained in:
Anthony Dresser
2019-03-19 17:44:35 -07:00
committed by GitHub
parent 833d197412
commit 87765e8673
1879 changed files with 54505 additions and 38058 deletions

View File

@@ -15,7 +15,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { ITextModel } from 'vs/editor/common/model';
import { ITextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
@@ -24,7 +24,7 @@ import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/co
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export const IKeybindingEditingService = createDecorator<IKeybindingEditingService>('keybindingEditingService');
@@ -32,7 +32,7 @@ export interface IKeybindingEditingService {
_serviceBrand: ServiceIdentifier<any>;
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void>;
editKeybinding(keybindingItem: ResolvedKeybindingItem, key: string, when: string | undefined): Promise<void>;
removeKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void>;
@@ -57,8 +57,8 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
this.queue = new Queue<void>();
}
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.queue.queue(() => this.doEditKeybinding(key, keybindingItem)); // queue up writes to prevent race conditions
editKeybinding(keybindingItem: ResolvedKeybindingItem, key: string, when: string | undefined): Promise<void> {
return this.queue.queue(() => this.doEditKeybinding(keybindingItem, key, when)); // queue up writes to prevent race conditions
}
resetKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void> {
@@ -69,13 +69,13 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return this.queue.queue(() => this.doRemoveKeybinding(keybindingItem)); // queue up writes to prevent race conditions
}
private doEditKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void> {
private doEditKeybinding(keybindingItem: ResolvedKeybindingItem, key: string, when: string | undefined): Promise<void> {
return this.resolveAndValidate()
.then(reference => {
const model = reference.object.textEditorModel;
const userKeybindingEntries = <IUserFriendlyKeybinding[]>json.parse(model.getValue());
const userKeybindingEntryIndex = this.findUserKeybindingEntryIndex(keybindingItem, userKeybindingEntries);
this.updateKeybinding(key, keybindingItem, model, userKeybindingEntryIndex);
this.updateKeybinding(keybindingItem, key, when, model, userKeybindingEntryIndex);
if (keybindingItem.isDefault && keybindingItem.resolvedKeybinding) {
this.removeDefaultKeybinding(keybindingItem, model);
}
@@ -112,15 +112,19 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return this.textFileService.save(this.resource);
}
private updateKeybinding(newKey: string, keybindingItem: ResolvedKeybindingItem, model: ITextModel, userKeybindingEntryIndex: number): void {
private updateKeybinding(keybindingItem: ResolvedKeybindingItem, newKey: string, when: string | undefined, model: ITextModel, userKeybindingEntryIndex: number): void {
const { tabSize, insertSpaces } = model.getOptions();
const eol = model.getEOL();
if (userKeybindingEntryIndex !== -1) {
// Update the keybinding with new key
this.applyEditsToBuffer(setProperty(model.getValue(), [userKeybindingEntryIndex, 'key'], newKey, { tabSize, insertSpaces, eol })[0], model);
const edits = setProperty(model.getValue(), [userKeybindingEntryIndex, 'when'], when, { tabSize, insertSpaces, eol });
if (edits.length > 0) {
this.applyEditsToBuffer(edits[0], model);
}
} else {
// Add the new keybinding with new key
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], this.asObject(newKey, keybindingItem.command, keybindingItem.when, false), { tabSize, insertSpaces, eol })[0], model);
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], this.asObject(newKey, keybindingItem.command, when, false), { tabSize, insertSpaces, eol })[0], model);
}
}
@@ -137,7 +141,10 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private removeDefaultKeybinding(keybindingItem: ResolvedKeybindingItem, model: ITextModel): void {
const { tabSize, insertSpaces } = model.getOptions();
const eol = model.getEOL();
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], this.asObject(keybindingItem.resolvedKeybinding.getUserSettingsLabel(), keybindingItem.command, keybindingItem.when, true), { tabSize, insertSpaces, eol })[0], model);
const key = keybindingItem.resolvedKeybinding ? keybindingItem.resolvedKeybinding.getUserSettingsLabel() : null;
if (key) {
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], this.asObject(key, keybindingItem.command, keybindingItem.when ? keybindingItem.when.serialize() : undefined, true), { tabSize, insertSpaces, eol })[0], model);
}
}
private removeUnassignedDefaultKeybinding(keybindingItem: ResolvedKeybindingItem, model: ITextModel): void {
@@ -158,7 +165,8 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return index;
}
if (keybinding.when && keybindingItem.when) {
if (ContextKeyExpr.deserialize(keybinding.when).serialize() === keybindingItem.when.serialize()) {
const contextKeyExpr = ContextKeyExpr.deserialize(keybinding.when);
if (contextKeyExpr && contextKeyExpr.serialize() === keybindingItem.when.serialize()) {
return index;
}
}
@@ -177,11 +185,13 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return indices;
}
private asObject(key: string, command: string, when: ContextKeyExpr, negate: boolean): any {
private asObject(key: string, command: string | null, when: string | undefined, negate: boolean): any {
const object = { key };
object['command'] = negate ? `-${command}` : command;
if (command) {
object['command'] = negate ? `-${command}` : command;
}
if (when) {
object['when'] = when.serialize();
object['when'] = when;
}
return object;
}
@@ -197,7 +207,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
}
private resolveModelReference(): Promise<IReference<ITextEditorModel>> {
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
return this.fileService.existsFile(this.resource)
.then(exists => {
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
@@ -206,7 +216,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
});
}
private resolveAndValidate(): Promise<IReference<ITextEditorModel>> {
private resolveAndValidate(): Promise<IReference<IResolvedTextEditorModel>> {
// Target cannot be dirty if not writing into buffer
if (this.textFileService.isDirty(this.resource)) {
@@ -220,11 +230,11 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
if (model.getValue()) {
const parsed = this.parse(model);
if (parsed.parseErrors.length) {
return Promise.reject(new Error(localize('parseErrors', "Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.")));
return Promise.reject<any>(new Error(localize('parseErrors', "Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.")));
}
if (parsed.result) {
if (!isArray(parsed.result)) {
return Promise.reject(new Error(localize('errorInvalidConfiguration', "Unable to write to the keybindings configuration file. It has an object which is not of type Array. Please open the file to clean up and try again.")));
return Promise.reject<any>(new Error(localize('errorInvalidConfiguration', "Unable to write to the keybindings configuration file. It has an object which is not of type Array. Please open the file to clean up and try again.")));
}
} else {
const content = EOL + '[]';
@@ -248,3 +258,5 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return '// ' + localize('emptyKeybindingsHeader', "Place your key bindings in this file to override the defaults") + EOL + '[]';
}
}
registerSingleton(IKeybindingEditingService, KeybindingsEditingService, true);

View File

@@ -5,15 +5,13 @@
import { SimpleKeybinding } from 'vs/base/common/keyCodes';
import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { OperatingSystem } from 'vs/base/common/platform';
import { ScanCodeBinding } from 'vs/base/common/scanCode';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
export interface IUserKeybindingItem {
firstPart: SimpleKeybinding | ScanCodeBinding | null;
chordPart: SimpleKeybinding | ScanCodeBinding | null;
parts: (SimpleKeybinding | ScanCodeBinding)[];
command: string | null;
commandArgs?: any;
when: ContextKeyExpr | null;
@@ -21,7 +19,7 @@ export interface IUserKeybindingItem {
export class KeybindingIO {
public static writeKeybindingItem(out: OutputBuilder, item: ResolvedKeybindingItem, OS: OperatingSystem): void {
public static writeKeybindingItem(out: OutputBuilder, item: ResolvedKeybindingItem): void {
if (!item.resolvedKeybinding) {
return;
}
@@ -41,14 +39,13 @@ export class KeybindingIO {
out.write('}');
}
public static readUserKeybindingItem(input: IUserFriendlyKeybinding, OS: OperatingSystem): IUserKeybindingItem {
const [firstPart, chordPart] = (typeof input.key === 'string' ? KeybindingParser.parseUserBinding(input.key) : [null, null]);
public static readUserKeybindingItem(input: IUserFriendlyKeybinding): IUserKeybindingItem {
const parts = (typeof input.key === 'string' ? KeybindingParser.parseUserBinding(input.key) : []);
const when = (typeof input.when === 'string' ? ContextKeyExpr.deserialize(input.when) : null);
const command = (typeof input.command === 'string' ? input.command : null);
const commandArgs = (typeof input.args !== 'undefined' ? input.args : undefined);
return {
firstPart: firstPart,
chordPart: chordPart,
parts: parts,
command: command,
commandArgs: commandArgs,
when: when

View File

@@ -11,7 +11,7 @@ export interface IKeyboardMapper {
dumpDebugInfo(): string;
resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[];
resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding;
resolveUserBinding(firstPart: SimpleKeybinding | ScanCodeBinding | null, chordPart: SimpleKeybinding | ScanCodeBinding | null): ResolvedKeybinding[];
resolveUserBinding(firstPart: (SimpleKeybinding | ScanCodeBinding)[]): ResolvedKeybinding[];
}
export class CachedKeyboardMapper implements IKeyboardMapper {
@@ -43,7 +43,7 @@ export class CachedKeyboardMapper implements IKeyboardMapper {
return this._actual.resolveKeyboardEvent(keyboardEvent);
}
public resolveUserBinding(firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding): ResolvedKeybinding[] {
return this._actual.resolveUserBinding(firstPart, chordPart);
public resolveUserBinding(parts: (SimpleKeybinding | ScanCodeBinding)[]): ResolvedKeybinding[] {
return this._actual.resolveUserBinding(parts);
}
}

View File

@@ -9,6 +9,7 @@ import { IMMUTABLE_CODE_TO_KEY_CODE, ScanCode, ScanCodeBinding } from 'vs/base/c
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboardMapper';
import { removeElementsAfterNulls } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
/**
* A keyboard mapper to be used when reading the keymap from the OS fails.
@@ -40,7 +41,7 @@ export class MacLinuxFallbackKeyboardMapper implements IKeyboardMapper {
keyboardEvent.metaKey,
keyboardEvent.keyCode
);
return new USLayoutResolvedKeybinding(keybinding, this._OS);
return new USLayoutResolvedKeybinding(keybinding.toChord(), this._OS);
}
private _scanCodeToKeyCode(scanCode: ScanCode): KeyCode {
@@ -117,14 +118,10 @@ export class MacLinuxFallbackKeyboardMapper implements IKeyboardMapper {
return new SimpleKeybinding(binding.ctrlKey, binding.shiftKey, binding.altKey, binding.metaKey, keyCode);
}
public resolveUserBinding(firstPart: SimpleKeybinding | ScanCodeBinding | null, chordPart: SimpleKeybinding | ScanCodeBinding | null): ResolvedKeybinding[] {
const _firstPart = this._resolveSimpleUserBinding(firstPart);
const _chordPart = this._resolveSimpleUserBinding(chordPart);
if (_firstPart && _chordPart) {
return [new USLayoutResolvedKeybinding(new ChordKeybinding(_firstPart, _chordPart), this._OS)];
}
if (_firstPart) {
return [new USLayoutResolvedKeybinding(_firstPart, this._OS)];
public resolveUserBinding(input: (SimpleKeybinding | ScanCodeBinding)[]): ResolvedKeybinding[] {
const parts: SimpleKeybinding[] = removeElementsAfterNulls(input.map(keybinding => this._resolveSimpleUserBinding(keybinding)));
if (parts.length > 0) {
return [new USLayoutResolvedKeybinding(new ChordKeybinding(parts), this._OS)];
}
return [];
}

View File

@@ -4,12 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import { CharCode } from 'vs/base/common/charCode';
import { KeyCode, KeyCodeUtils, Keybinding, KeybindingType, ResolvedKeybinding, ResolvedKeybindingPart, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { AriaLabelProvider, ElectronAcceleratorLabelProvider, UILabelProvider, UserSettingsLabelProvider } from 'vs/base/common/keybindingLabels';
import { KeyCode, KeyCodeUtils, Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { OperatingSystem } from 'vs/base/common/platform';
import { IMMUTABLE_CODE_TO_KEY_CODE, IMMUTABLE_KEY_CODE_TO_CODE, ScanCode, ScanCodeBinding, ScanCodeUtils } from 'vs/base/common/scanCode';
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboardMapper';
import { BaseResolvedKeybinding } from 'vs/platform/keybinding/common/baseResolvedKeybinding';
export interface IMacLinuxKeyMapping {
value: string;
@@ -63,53 +63,32 @@ export function macLinuxKeyboardMappingEquals(a: IMacLinuxKeyboardMapping | null
*/
const CHAR_CODE_TO_KEY_CODE: ({ keyCode: KeyCode; shiftKey: boolean } | null)[] = [];
export class NativeResolvedKeybinding extends ResolvedKeybinding {
export class NativeResolvedKeybinding extends BaseResolvedKeybinding<ScanCodeBinding> {
private readonly _mapper: MacLinuxKeyboardMapper;
private readonly _OS: OperatingSystem;
private readonly _firstPart: ScanCodeBinding;
private readonly _chordPart: ScanCodeBinding | null;
constructor(mapper: MacLinuxKeyboardMapper, OS: OperatingSystem, firstPart: ScanCodeBinding, chordPart: ScanCodeBinding | null) {
super();
if (!firstPart) {
throw new Error(`Invalid USLayoutResolvedKeybinding`);
}
constructor(mapper: MacLinuxKeyboardMapper, os: OperatingSystem, parts: ScanCodeBinding[]) {
super(os, parts);
this._mapper = mapper;
this._OS = OS;
this._firstPart = firstPart;
this._chordPart = chordPart;
}
public getLabel(): string | null {
let firstPart = this._mapper.getUILabelForScanCodeBinding(this._firstPart);
let chordPart = this._mapper.getUILabelForScanCodeBinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
protected _getLabel(keybinding: ScanCodeBinding): string | null {
return this._mapper.getUILabelForScanCodeBinding(keybinding);
}
public getAriaLabel(): string | null {
let firstPart = this._mapper.getAriaLabelForScanCodeBinding(this._firstPart);
let chordPart = this._mapper.getAriaLabelForScanCodeBinding(this._chordPart);
return AriaLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
protected _getAriaLabel(keybinding: ScanCodeBinding): string | null {
return this._mapper.getAriaLabelForScanCodeBinding(keybinding);
}
public getElectronAccelerator(): string | null {
if (this._chordPart !== null) {
// Electron cannot handle chords
return null;
}
let firstPart = this._mapper.getElectronAcceleratorLabelForScanCodeBinding(this._firstPart);
return ElectronAcceleratorLabelProvider.toLabel(this._firstPart, firstPart, null, null, this._OS);
protected _getElectronAccelerator(keybinding: ScanCodeBinding): string | null {
return this._mapper.getElectronAcceleratorLabelForScanCodeBinding(keybinding);
}
public getUserSettingsLabel(): string | null {
let firstPart = this._mapper.getUserSettingsLabelForScanCodeBinding(this._firstPart);
let chordPart = this._mapper.getUserSettingsLabelForScanCodeBinding(this._chordPart);
return UserSettingsLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
protected _getUserSettingsLabel(keybinding: ScanCodeBinding): string | null {
return this._mapper.getUserSettingsLabelForScanCodeBinding(keybinding);
}
private _isWYSIWYG(binding: ScanCodeBinding | null): boolean {
protected _isWYSIWYG(binding: ScanCodeBinding | null): boolean {
if (!binding) {
return true;
}
@@ -128,36 +107,8 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
return (a.toLowerCase() === b.toLowerCase());
}
public isWYSIWYG(): boolean {
return (this._isWYSIWYG(this._firstPart) && this._isWYSIWYG(this._chordPart));
}
public isChord(): boolean {
return (this._chordPart ? true : false);
}
public getParts(): [ResolvedKeybindingPart, ResolvedKeybindingPart | null] {
return [
this._toResolvedKeybindingPart(this._firstPart),
this._chordPart ? this._toResolvedKeybindingPart(this._chordPart) : null
];
}
private _toResolvedKeybindingPart(binding: ScanCodeBinding): ResolvedKeybindingPart {
return new ResolvedKeybindingPart(
binding.ctrlKey,
binding.shiftKey,
binding.altKey,
binding.metaKey,
this._mapper.getUILabelForScanCodeBinding(binding),
this._mapper.getAriaLabelForScanCodeBinding(binding)
);
}
public getDispatchParts(): [string | null, string | null] {
let firstPart = this._firstPart ? this._mapper.getDispatchStrForScanCodeBinding(this._firstPart) : null;
let chordPart = this._chordPart ? this._mapper.getDispatchStrForScanCodeBinding(this._chordPart) : null;
return [firstPart, chordPart];
protected _getDispatchPart(keybinding: ScanCodeBinding): string | null {
return this._mapper.getDispatchStrForScanCodeBinding(keybinding);
}
}
@@ -774,6 +725,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
const hwAltKey = (mod & 0b100) ? true : false;
const scanCodeCombo = new ScanCodeCombo(hwCtrlKey, hwShiftKey, hwAltKey, scanCode);
const resolvedKb = this.resolveKeyboardEvent({
_standardKeyboardEventBrand: true,
ctrlKey: scanCodeCombo.ctrlKey,
shiftKey: scanCodeCombo.shiftKey,
altKey: scanCodeCombo.altKey,
@@ -1012,31 +964,33 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
public resolveKeybinding(keybinding: Keybinding): NativeResolvedKeybinding[] {
let result: NativeResolvedKeybinding[] = [], resultLen = 0;
let chordParts: ScanCodeBinding[][] = [];
for (let part of keybinding.parts) {
chordParts.push(this.simpleKeybindingToScanCodeBinding(part));
}
return this._toResolvedKeybinding(chordParts);
}
if (keybinding.type === KeybindingType.Chord) {
const firstParts = this.simpleKeybindingToScanCodeBinding(keybinding.firstPart);
const chordParts = this.simpleKeybindingToScanCodeBinding(keybinding.chordPart);
private _toResolvedKeybinding(chordParts: ScanCodeBinding[][]): NativeResolvedKeybinding[] {
if (chordParts.length === 0) {
return [];
}
let result: NativeResolvedKeybinding[] = [];
this._generateResolvedKeybindings(chordParts, 0, [], result);
return result;
}
for (let i = 0, len = firstParts.length; i < len; i++) {
const firstPart = firstParts[i];
for (let j = 0, lenJ = chordParts.length; j < lenJ; j++) {
const chordPart = chordParts[j];
result[resultLen++] = new NativeResolvedKeybinding(this, this._OS, firstPart, chordPart);
}
}
} else {
const firstParts = this.simpleKeybindingToScanCodeBinding(keybinding);
for (let i = 0, len = firstParts.length; i < len; i++) {
const firstPart = firstParts[i];
result[resultLen++] = new NativeResolvedKeybinding(this, this._OS, firstPart, null);
private _generateResolvedKeybindings(chordParts: ScanCodeBinding[][], currentIndex: number, previousParts: ScanCodeBinding[], result: NativeResolvedKeybinding[]) {
const chordPart = chordParts[currentIndex];
const isFinalIndex = currentIndex === chordParts.length - 1;
for (let i = 0, len = chordPart.length; i < len; i++) {
let chords = [...previousParts, chordPart[i]];
if (isFinalIndex) {
result.push(new NativeResolvedKeybinding(this, this._OS, chords));
} else {
this._generateResolvedKeybindings(chordParts, currentIndex + 1, chords, result);
}
}
return result;
}
public resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): NativeResolvedKeybinding {
@@ -1094,7 +1048,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
const keypress = new ScanCodeBinding(keyboardEvent.ctrlKey, keyboardEvent.shiftKey, keyboardEvent.altKey, keyboardEvent.metaKey, code);
return new NativeResolvedKeybinding(this, this._OS, keypress, null);
return new NativeResolvedKeybinding(this, this._OS, [keypress]);
}
private _resolveSimpleUserBinding(binding: SimpleKeybinding | ScanCodeBinding | null): ScanCodeBinding[] {
@@ -1107,24 +1061,9 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
return this.simpleKeybindingToScanCodeBinding(binding);
}
public resolveUserBinding(_firstPart: SimpleKeybinding | ScanCodeBinding | null, _chordPart: SimpleKeybinding | ScanCodeBinding | null): ResolvedKeybinding[] {
const firstParts = this._resolveSimpleUserBinding(_firstPart);
const chordParts = this._resolveSimpleUserBinding(_chordPart);
let result: NativeResolvedKeybinding[] = [], resultLen = 0;
for (let i = 0, len = firstParts.length; i < len; i++) {
const firstPart = firstParts[i];
if (_chordPart) {
for (let j = 0, lenJ = chordParts.length; j < lenJ; j++) {
const chordPart = chordParts[j];
result[resultLen++] = new NativeResolvedKeybinding(this, this._OS, firstPart, chordPart);
}
} else {
result[resultLen++] = new NativeResolvedKeybinding(this, this._OS, firstPart, null);
}
}
return result;
public resolveUserBinding(input: (SimpleKeybinding | ScanCodeBinding)[]): ResolvedKeybinding[] {
const parts: ScanCodeBinding[][] = input.map(keybinding => this._resolveSimpleUserBinding(keybinding));
return this._toResolvedKeybinding(parts);
}
private static _charCodeToKb(charCode: number): { keyCode: KeyCode; shiftKey: boolean } | null {

View File

@@ -4,12 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import { CharCode } from 'vs/base/common/charCode';
import { KeyCode, KeyCodeUtils, Keybinding, KeybindingType, ResolvedKeybinding, ResolvedKeybindingPart, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { AriaLabelProvider, ElectronAcceleratorLabelProvider, UILabelProvider, UserSettingsLabelProvider } from 'vs/base/common/keybindingLabels';
import { KeyCode, KeyCodeUtils, Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { UILabelProvider } from 'vs/base/common/keybindingLabels';
import { OperatingSystem } from 'vs/base/common/platform';
import { IMMUTABLE_CODE_TO_KEY_CODE, ScanCode, ScanCodeBinding, ScanCodeUtils } from 'vs/base/common/scanCode';
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboardMapper';
import { BaseResolvedKeybinding } from 'vs/platform/keybinding/common/baseResolvedKeybinding';
import { removeElementsAfterNulls } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
export interface IWindowsKeyMapping {
vkey: string;
@@ -76,42 +78,23 @@ export interface IScanCodeMapping {
withShiftAltGr: string;
}
export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
export class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding<SimpleKeybinding> {
private readonly _mapper: WindowsKeyboardMapper;
private readonly _firstPart: SimpleKeybinding;
private readonly _chordPart: SimpleKeybinding | null;
constructor(mapper: WindowsKeyboardMapper, firstPart: SimpleKeybinding, chordPart: SimpleKeybinding | null) {
super();
if (!firstPart) {
throw new Error(`Invalid WindowsNativeResolvedKeybinding firstPart`);
}
constructor(mapper: WindowsKeyboardMapper, parts: SimpleKeybinding[]) {
super(OperatingSystem.Windows, parts);
this._mapper = mapper;
this._firstPart = firstPart;
this._chordPart = chordPart;
}
private _getUILabelForKeybinding(keybinding: SimpleKeybinding | null): string | null {
if (!keybinding) {
return null;
}
protected _getLabel(keybinding: SimpleKeybinding): string | null {
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getUILabelForKeyCode(keybinding.keyCode);
}
public getLabel(): string | null {
let firstPart = this._getUILabelForKeybinding(this._firstPart);
let chordPart = this._getUILabelForKeybinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
}
private _getUSLabelForKeybinding(keybinding: SimpleKeybinding | null): string | null {
if (!keybinding) {
return null;
}
private _getUSLabelForKeybinding(keybinding: SimpleKeybinding): string | null {
if (keybinding.isDuplicateModifierCase()) {
return '';
}
@@ -119,27 +102,16 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
}
public getUSLabel(): string | null {
let firstPart = this._getUSLabelForKeybinding(this._firstPart);
let chordPart = this._getUSLabelForKeybinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
return UILabelProvider.toLabel(this._os, this._parts, (keybinding) => this._getUSLabelForKeybinding(keybinding));
}
private _getAriaLabelForKeybinding(keybinding: SimpleKeybinding | null): string | null {
if (!keybinding) {
return null;
}
protected _getAriaLabel(keybinding: SimpleKeybinding): string | null {
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getAriaLabelForKeyCode(keybinding.keyCode);
}
public getAriaLabel(): string | null {
let firstPart = this._getAriaLabelForKeybinding(this._firstPart);
let chordPart = this._getAriaLabelForKeybinding(this._chordPart);
return AriaLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
}
private _keyCodeToElectronAccelerator(keyCode: KeyCode): string | null {
if (keyCode >= KeyCode.NUMPAD_0 && keyCode <= KeyCode.NUMPAD_DIVIDE) {
// Electron cannot handle numpad keys
@@ -161,54 +133,26 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return KeyCodeUtils.toString(keyCode);
}
private _getElectronAcceleratorLabelForKeybinding(keybinding: SimpleKeybinding | null): string | null {
if (!keybinding) {
return null;
}
protected _getElectronAccelerator(keybinding: SimpleKeybinding): string | null {
if (keybinding.isDuplicateModifierCase()) {
return null;
}
return this._keyCodeToElectronAccelerator(keybinding.keyCode);
}
public getElectronAccelerator(): string | null {
if (this._chordPart !== null) {
// Electron cannot handle chords
return null;
}
let firstPart = this._getElectronAcceleratorLabelForKeybinding(this._firstPart);
return ElectronAcceleratorLabelProvider.toLabel(this._firstPart, firstPart, null, null, OperatingSystem.Windows);
}
private _getUserSettingsLabelForKeybinding(keybinding: SimpleKeybinding | null): string | null {
if (!keybinding) {
return null;
}
protected _getUserSettingsLabel(keybinding: SimpleKeybinding): string | null {
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getUserSettingsLabelForKeyCode(keybinding.keyCode);
}
public getUserSettingsLabel(): string | null {
let firstPart = this._getUserSettingsLabelForKeybinding(this._firstPart);
let chordPart = this._getUserSettingsLabelForKeybinding(this._chordPart);
let result = UserSettingsLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
const result = this._mapper.getUserSettingsLabelForKeyCode(keybinding.keyCode);
return (result ? result.toLowerCase() : result);
}
public isWYSIWYG(): boolean {
if (this._firstPart && !this._isWYSIWYG(this._firstPart.keyCode)) {
return false;
}
if (this._chordPart && !this._isWYSIWYG(this._chordPart.keyCode)) {
return false;
}
return true;
protected _isWYSIWYG(keybinding: SimpleKeybinding): boolean {
return this.__isWYSIWYG(keybinding.keyCode);
}
private _isWYSIWYG(keyCode: KeyCode): boolean {
private __isWYSIWYG(keyCode: KeyCode): boolean {
if (
keyCode === KeyCode.LeftArrow
|| keyCode === KeyCode.UpArrow
@@ -222,35 +166,7 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return (ariaLabel === userSettingsLabel);
}
public isChord(): boolean {
return (this._chordPart ? true : false);
}
public getParts(): [ResolvedKeybindingPart, ResolvedKeybindingPart | null] {
return [
this._toResolvedKeybindingPart(this._firstPart),
this._chordPart ? this._toResolvedKeybindingPart(this._chordPart) : null
];
}
private _toResolvedKeybindingPart(keybinding: SimpleKeybinding): ResolvedKeybindingPart {
return new ResolvedKeybindingPart(
keybinding.ctrlKey,
keybinding.shiftKey,
keybinding.altKey,
keybinding.metaKey,
this._getUILabelForKeybinding(keybinding),
this._getAriaLabelForKeybinding(keybinding)
);
}
public getDispatchParts(): [string | null, string | null] {
let firstPart = this._firstPart ? this._getDispatchStr(this._firstPart) : null;
let chordPart = this._chordPart ? this._getDispatchStr(this._chordPart) : null;
return [firstPart, chordPart];
}
private _getDispatchStr(keybinding: SimpleKeybinding): string | null {
protected _getDispatchPart(keybinding: SimpleKeybinding): string | null {
if (keybinding.isModifierKey()) {
return null;
}
@@ -468,7 +384,7 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
const scanCodeBinding = new ScanCodeBinding(ctrlKey, shiftKey, altKey, false, scanCode);
const kb = this._resolveSimpleUserBinding(scanCodeBinding);
const strKeyCode = (kb ? KeyCodeUtils.toString(kb.keyCode) : null);
const resolvedKb = (kb ? new WindowsNativeResolvedKeybinding(this, kb, null) : null);
const resolvedKb = (kb ? new WindowsNativeResolvedKeybinding(this, [kb]) : null);
const outScanCode = `${ctrlKey ? 'Ctrl+' : ''}${shiftKey ? 'Shift+' : ''}${altKey ? 'Alt+' : ''}${strCode}`;
const ariaLabel = (resolvedKb ? resolvedKb.getAriaLabel() : null);
@@ -517,24 +433,19 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
}
public resolveKeybinding(keybinding: Keybinding): WindowsNativeResolvedKeybinding[] {
if (keybinding.type === KeybindingType.Chord) {
const firstPartKeyCode = keybinding.firstPart.keyCode;
const chordPartKeyCode = keybinding.chordPart.keyCode;
if (!this._keyCodeExists[firstPartKeyCode] || !this._keyCodeExists[chordPartKeyCode]) {
const parts = keybinding.parts;
for (let i = 0, len = parts.length; i < len; i++) {
const part = parts[i];
if (!this._keyCodeExists[part.keyCode]) {
return [];
}
return [new WindowsNativeResolvedKeybinding(this, keybinding.firstPart, keybinding.chordPart)];
} else {
if (!this._keyCodeExists[keybinding.keyCode]) {
return [];
}
return [new WindowsNativeResolvedKeybinding(this, keybinding, null)];
}
return [new WindowsNativeResolvedKeybinding(this, parts)];
}
public resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): WindowsNativeResolvedKeybinding {
const keybinding = new SimpleKeybinding(keyboardEvent.ctrlKey, keyboardEvent.shiftKey, keyboardEvent.altKey, keyboardEvent.metaKey, keyboardEvent.keyCode);
return new WindowsNativeResolvedKeybinding(this, keybinding, null);
return new WindowsNativeResolvedKeybinding(this, [keybinding]);
}
private _resolveSimpleUserBinding(binding: SimpleKeybinding | ScanCodeBinding | null): SimpleKeybinding | null {
@@ -554,14 +465,10 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
return new SimpleKeybinding(binding.ctrlKey, binding.shiftKey, binding.altKey, binding.metaKey, keyCode);
}
public resolveUserBinding(firstPart: SimpleKeybinding | ScanCodeBinding | null, chordPart: SimpleKeybinding | ScanCodeBinding | null): ResolvedKeybinding[] {
const _firstPart = this._resolveSimpleUserBinding(firstPart);
const _chordPart = this._resolveSimpleUserBinding(chordPart);
if (_firstPart && _chordPart) {
return [new WindowsNativeResolvedKeybinding(this, _firstPart, _chordPart)];
}
if (_firstPart) {
return [new WindowsNativeResolvedKeybinding(this, _firstPart, null)];
public resolveUserBinding(input: (SimpleKeybinding | ScanCodeBinding)[]): ResolvedKeybinding[] {
const parts: SimpleKeybinding[] = removeElementsAfterNulls(input.map(keybinding => this._resolveSimpleUserBinding(keybinding)));
if (parts.length > 0) {
return [new WindowsNativeResolvedKeybinding(this, parts)];
}
return [];
}

View File

@@ -15,14 +15,14 @@ import { Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { OS, OperatingSystem } from 'vs/base/common/platform';
import { ConfigWatcher } from 'vs/base/node/config';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Extensions as ConfigExtensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
import { IKeybindingEvent, IKeyboardEvent, IUserFriendlyKeybinding, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
import { IKeybindingEvent, IKeyboardEvent, IUserFriendlyKeybinding, KeybindingSource, IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
import { IKeybindingItem, IKeybindingRule2, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
@@ -38,6 +38,9 @@ import { MacLinuxFallbackKeyboardMapper } from 'vs/workbench/services/keybinding
import { IMacLinuxKeyboardMapping, MacLinuxKeyboardMapper, macLinuxKeyboardMappingEquals } from 'vs/workbench/services/keybinding/common/macLinuxKeyboardMapper';
import { IWindowsKeyboardMapping, WindowsKeyboardMapper, windowsKeyboardMappingEquals } from 'vs/workbench/services/keybinding/common/windowsKeyboardMapper';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { MenuRegistry } from 'vs/platform/actions/common/actions';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class KeyboardMapperFactory {
public static readonly INSTANCE = new KeyboardMapperFactory();
@@ -235,7 +238,6 @@ let keybindingType: IJSONSchema = {
};
const keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedKeyBinding | ContributedKeyBinding[]>({
isDynamic: true,
extensionPoint: 'keybindings',
jsonSchema: {
description: nls.localize('vscode.extension.contributes.keybindings', "Contributes keybindings."),
@@ -268,7 +270,6 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
private userKeybindings: ConfigWatcher<IUserFriendlyKeybinding[]>;
constructor(
windowElement: Window,
@IContextKeyService contextKeyService: IContextKeyService,
@ICommandService commandService: ICommandService,
@ITelemetryService telemetryService: ITelemetryService,
@@ -276,10 +277,13 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
@IEnvironmentService environmentService: IEnvironmentService,
@IStatusbarService statusBarService: IStatusbarService,
@IConfigurationService configurationService: IConfigurationService,
@IWindowService private readonly windowService: IWindowService
@IWindowService private readonly windowService: IWindowService,
@IExtensionService extensionService: IExtensionService
) {
super(contextKeyService, commandService, telemetryService, notificationService, statusBarService);
updateSchema();
let dispatchConfig = getDispatchConfig(configurationService);
configurationService.onDidChangeConfiguration((e) => {
let newDispatchConfig = getDispatchConfig(configurationService);
@@ -314,12 +318,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
this.updateResolver({ source: KeybindingSource.Default });
});
updateSchema();
this._register(extensionService.onDidRegisterExtensions(() => updateSchema()));
this._register(this.userKeybindings.onDidUpdateConfiguration(event => this.updateResolver({
source: KeybindingSource.User,
keybindings: event.config
})));
this._register(dom.addDisposableListener(windowElement, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
this._register(dom.addDisposableListener(window, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
let keyEvent = new StandardKeyboardEvent(e);
let shouldPreventDefault = this._dispatch(keyEvent, keyEvent.target);
if (shouldPreventDefault) {
@@ -339,7 +346,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
});
}
public dumpDebugInfo(): string {
public _dumpDebugInfo(): string {
const layoutInfo = JSON.stringify(KeyboardMapperFactory.INSTANCE.getCurrentKeyboardLayout(), null, '\t');
const mapperInfo = this._keyboardMapper.dumpDebugInfo();
const rawMapping = JSON.stringify(KeyboardMapperFactory.INSTANCE.getRawKeyboardMapping(), null, '\t');
@@ -405,13 +412,12 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (const item of items) {
const when = (item.when ? item.when.normalize() : null);
const firstPart = item.firstPart;
const chordPart = item.chordPart;
if (!firstPart) {
const parts = item.parts;
if (parts.length === 0) {
// This might be a removal keybinding item in user settings => accept it
result[resultLen++] = new ResolvedKeybindingItem(null, item.command, item.commandArgs, when, isDefault);
} else {
const resolvedKeybindings = this._keyboardMapper.resolveUserBinding(firstPart, chordPart);
const resolvedKeybindings = this._keyboardMapper.resolveUserBinding(parts);
for (const resolvedKeybinding of resolvedKeybindings) {
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
}
@@ -436,7 +442,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
});
}
return extraUserKeybindings.map((k) => KeybindingIO.readUserKeybindingItem(k, OS));
return extraUserKeybindings.map((k) => KeybindingIO.readUserKeybindingItem(k));
}
public resolveKeybinding(kb: Keybinding): ResolvedKeybinding[] {
@@ -448,8 +454,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}
public resolveUserBinding(userBinding: string): ResolvedKeybinding[] {
const [firstPart, chordPart] = KeybindingParser.parseUserBinding(userBinding);
return this._keyboardMapper.resolveUserBinding(firstPart, chordPart);
const parts = KeybindingParser.parseUserBinding(userBinding);
return this._keyboardMapper.resolveUserBinding(parts);
}
private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings: ContributedKeyBinding | ContributedKeyBinding[], collector: ExtensionMessageCollector, result: IKeybindingRule2[]): void {
@@ -529,7 +535,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
let lastIndex = defaultKeybindings.length - 1;
defaultKeybindings.forEach((k, index) => {
KeybindingIO.writeKeybindingItem(out, k, OS);
KeybindingIO.writeKeybindingItem(out, k);
if (index !== lastIndex) {
out.writeLine(',');
} else {
@@ -569,10 +575,31 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}
let schemaId = 'vscode://schemas/keybindings';
let commandsSchemas: IJSONSchema[] = [];
let commandsEnum: string[] = [];
let commandsEnumDescriptions: (string | null | undefined)[] = [];
let schema: IJSONSchema = {
'id': schemaId,
'type': 'array',
'title': nls.localize('keybindings.json.title', "Keybindings configuration"),
'definitions': {
'editorGroupsSchema': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'groups': {
'$ref': '#/definitions/editorGroupsSchema',
'default': [{}, {}]
},
'size': {
'type': 'number',
'default': 0.5
}
}
}
}
},
'items': {
'required': ['key'],
'type': 'object',
@@ -584,6 +611,8 @@ let schema: IJSONSchema = {
},
'command': {
'type': 'string',
'enum': commandsEnum,
'enumDescriptions': <any>commandsEnumDescriptions,
'description': nls.localize('keybindings.json.command', "Name of the command to execute"),
},
'when': {
@@ -593,13 +622,71 @@ let schema: IJSONSchema = {
'args': {
'description': nls.localize('keybindings.json.args', "Arguments to pass to the command to execute.")
}
}
},
'allOf': commandsSchemas
}
};
let schemaRegistry = Registry.as<IJSONContributionRegistry>(Extensions.JSONContribution);
schemaRegistry.registerSchema(schemaId, schema);
function updateSchema() {
commandsSchemas.length = 0;
commandsEnum.length = 0;
commandsEnumDescriptions.length = 0;
const knownCommands = new Set<string>();
const addKnownCommand = (commandId: string, description?: string | null) => {
if (!/^_/.test(commandId)) {
if (!knownCommands.has(commandId)) {
knownCommands.add(commandId);
commandsEnum.push(commandId);
commandsEnumDescriptions.push(description);
// Also add the negative form for keybinding removal
commandsEnum.push(`-${commandId}`);
commandsEnumDescriptions.push(description);
}
}
};
const allCommands = CommandsRegistry.getCommands();
for (let commandId in allCommands) {
const commandDescription = allCommands[commandId].description;
addKnownCommand(commandId, commandDescription && commandDescription.description);
if (!commandDescription || !commandDescription.args || commandDescription.args.length !== 1 || !commandDescription.args[0].schema) {
continue;
}
const argsSchema = commandDescription.args[0].schema;
const argsRequired = Array.isArray(argsSchema.required) && argsSchema.required.length > 0;
const addition = {
'if': {
'properties': {
'command': { 'const': commandId }
}
},
'then': {
'required': (<string[]>[]).concat(argsRequired ? ['args'] : []),
'properties': {
'args': argsSchema
}
}
};
commandsSchemas.push(addition);
}
const menuCommands = MenuRegistry.getCommands();
for (let commandId in menuCommands) {
addKnownCommand(commandId);
}
}
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration);
const keyboardConfiguration: IConfigurationNode = {
'id': 'keyboard',
@@ -625,3 +712,5 @@ const keyboardConfiguration: IConfigurationNode = {
};
configurationRegistry.registerConfiguration(keyboardConfiguration);
registerSingleton(IKeybindingService, WorkbenchKeybindingService);

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as path from 'vs/base/common/path';
import * as json from 'vs/base/common/json';
import { ChordKeybinding, KeyCode, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { OS } from 'vs/base/common/platform';
@@ -38,14 +38,13 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import { IWorkspaceContextService, Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { TestBackupFileService, TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestHashService, TestLifecycleService, TestLogService, TestStorageService, TestTextFileService, TestTextResourceConfigurationService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { TestBackupFileService, TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestLifecycleService, TestLogService, TestStorageService, TestTextFileService, TestTextResourceConfigurationService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
interface Modifiers {
metaKey?: boolean;
@@ -76,7 +75,6 @@ suite('KeybindingsEditing', () => {
const lifecycleService = new TestLifecycleService();
instantiationService.stub(ILifecycleService, lifecycleService);
instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
instantiationService.stub(IHashService, new TestHashService());
instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService());
instantiationService.stub(IEditorService, new TestEditorService());
instantiationService.stub(ITelemetryService, NullTelemetryService);
@@ -120,28 +118,28 @@ suite('KeybindingsEditing', () => {
test('errors cases - parse errors', () => {
fs.writeFileSync(keybindingsFile, ',,,,,,,,,,,,,,');
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined)
.then(() => assert.fail('Should fail with parse errors'),
error => assert.equal(error.message, 'Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.'));
});
test('errors cases - parse errors 2', () => {
fs.writeFileSync(keybindingsFile, '[{"key": }]');
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined)
.then(() => assert.fail('Should fail with parse errors'),
error => assert.equal(error.message, 'Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.'));
});
test('errors cases - dirty', () => {
instantiationService.stub(ITextFileService, 'isDirty', true);
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined)
.then(() => assert.fail('Should fail with dirty error'),
error => assert.equal(error.message, 'Unable to write because the keybindings configuration file is dirty. Please save it first and then try again.'));
});
test('errors cases - did not find an array', () => {
fs.writeFileSync(keybindingsFile, '{"key": "alt+c", "command": "hello"}');
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined)
.then(() => assert.fail('Should fail with dirty error'),
error => assert.equal(error.message, 'Unable to write to the keybindings configuration file. It has an object which is not of type Array. Please open the file to clean up and try again.'));
});
@@ -149,7 +147,7 @@ suite('KeybindingsEditing', () => {
test('edit a default keybinding to an empty file', () => {
fs.writeFileSync(keybindingsFile, '');
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
@@ -159,41 +157,41 @@ suite('KeybindingsEditing', () => {
testObject = instantiationService.createInstance(KeybindingsEditingService);
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('edit a default keybinding to an empty array', () => {
writeToKeybindingsFile();
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('edit a default keybinding in an existing array', () => {
writeToKeybindingsFile({ command: 'b', key: 'shift+c' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'shift+c', command: 'b' }, { key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('add a new default keybinding', () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ command: 'a' }))
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a' }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('edit an user keybinding', () => {
writeToKeybindingsFile({ key: 'escape', command: 'b' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'b' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('edit an user keybinding with more than one element', () => {
writeToKeybindingsFile({ key: 'escape', command: 'b' }, { key: 'alt+shift+g', command: 'c' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'b' }, { key: 'alt+shift+g', command: 'c' }];
return testObject.editKeybinding('alt+c', aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }))
return testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }), 'alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
@@ -232,7 +230,35 @@ suite('KeybindingsEditing', () => {
test('add a new keybinding to unassigned keybinding', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-a' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }, { key: 'shift+alt+c', command: 'a' }];
return testObject.editKeybinding('shift+alt+c', aResolvedKeybindingItem({ command: 'a', isDefault: false }))
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('add when expression', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-a' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }, { key: 'shift+alt+c', command: 'a', when: 'editorTextFocus' }];
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', 'editorTextFocus')
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('update command and when expression', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' }, { key: 'shift+alt+c', command: 'a', when: 'editorTextFocus' }];
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', 'editorTextFocus')
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('update when expression', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' }, { key: 'shift+alt+c', command: 'a', when: 'editorTextFocus && !editorReadonly' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' }, { key: 'shift+alt+c', command: 'a', when: 'editorTextFocus' }];
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false, when: 'editorTextFocus && !editorReadonly' }), 'shift+alt+c', 'editorTextFocus')
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('remove when expression', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a', when: 'editorTextFocus && !editorReadonly' }, { key: 'shift+alt+c', command: 'a' }];
return testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', undefined)
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
@@ -249,8 +275,15 @@ suite('KeybindingsEditing', () => {
const { ctrlKey, shiftKey, altKey, metaKey } = part.modifiers || { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false };
return new SimpleKeybinding(ctrlKey!, shiftKey!, altKey!, metaKey!, part.keyCode);
};
const keybinding = firstPart ? chordPart ? new ChordKeybinding(aSimpleKeybinding(firstPart), aSimpleKeybinding(chordPart)) : aSimpleKeybinding(firstPart) : null;
return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === undefined ? true : isDefault);
let parts: SimpleKeybinding[] = [];
if (firstPart) {
parts.push(aSimpleKeybinding(firstPart));
if (chordPart) {
parts.push(aSimpleKeybinding(chordPart));
}
}
let keybinding = parts.length > 0 ? new USLayoutResolvedKeybinding(new ChordKeybinding(parts), OS) : null;
return new ResolvedKeybindingItem(keybinding, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === undefined ? true : isDefault);
}
});

View File

@@ -5,7 +5,7 @@
import * as assert from 'assert';
import { KeyChord, KeyCode, KeyMod, SimpleKeybinding, createKeybinding } from 'vs/base/common/keyCodes';
import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { OS, OperatingSystem } from 'vs/base/common/platform';
import { OperatingSystem } from 'vs/base/common/platform';
import { ScanCode, ScanCodeBinding } from 'vs/base/common/scanCode';
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
@@ -126,37 +126,35 @@ suite('keybindingIO', () => {
test('issue #10452 - invalid command', () => {
let strJSON = `[{ "key": "ctrl+k ctrl+f", "command": ["firstcommand", "seccondcommand"] }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding, OS);
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding);
assert.equal(keybindingItem.command, null);
});
test('issue #10452 - invalid when', () => {
let strJSON = `[{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [] }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding, OS);
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding);
assert.equal(keybindingItem.when, null);
});
test('issue #10452 - invalid key', () => {
let strJSON = `[{ "key": [], "command": "firstcommand" }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding, OS);
assert.equal(keybindingItem.firstPart, null);
assert.equal(keybindingItem.chordPart, null);
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding);
assert.deepEqual(keybindingItem.parts, []);
});
test('issue #10452 - invalid key 2', () => {
let strJSON = `[{ "key": "", "command": "firstcommand" }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding, OS);
assert.equal(keybindingItem.firstPart, null);
assert.equal(keybindingItem.chordPart, null);
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding);
assert.deepEqual(keybindingItem.parts, []);
});
test('test commands args', () => {
let strJSON = `[{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [], "args": { "text": "theText" } }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding, OS);
let keybindingItem = KeybindingIO.readUserKeybindingItem(userKeybinding);
assert.equal(keybindingItem.commandArgs.text, 'theText');
});
});

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as path from 'path';
import * as path from 'vs/base/common/path';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { ScanCodeBinding } from 'vs/base/common/scanCode';
@@ -19,7 +19,7 @@ export interface IResolvedKeybinding {
userSettingsLabel: string | null;
isWYSIWYG: boolean;
isChord: boolean;
dispatchParts: [string | null, string | null];
dispatchParts: (string | null)[];
}
function toIResolvedKeybinding(kb: ResolvedKeybinding): IResolvedKeybinding {
@@ -44,8 +44,8 @@ export function assertResolveKeyboardEvent(mapper: IKeyboardMapper, keyboardEven
assert.deepEqual(actual, expected);
}
export function assertResolveUserBinding(mapper: IKeyboardMapper, firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding | null, expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveUserBinding(firstPart, chordPart).map(toIResolvedKeybinding);
export function assertResolveUserBinding(mapper: IKeyboardMapper, parts: (SimpleKeybinding | ScanCodeBinding)[], expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveUserBinding(parts).map(toIResolvedKeybinding);
assert.deepEqual(actual, expected);
}

View File

@@ -27,7 +27,7 @@ suite('keyboardMapper - MAC fallback', () => {
userSettingsLabel: 'cmd+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+Z', null],
dispatchParts: ['meta+Z'],
}]
);
});
@@ -51,6 +51,7 @@ suite('keyboardMapper - MAC fallback', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -65,16 +66,21 @@ suite('keyboardMapper - MAC fallback', () => {
userSettingsLabel: 'cmd+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+Z', null],
dispatchParts: ['meta+Z'],
}
);
});
test('resolveUserBinding empty', () => {
assertResolveUserBinding(mapper, [], []);
});
test('resolveUserBinding Cmd+[Comma] Cmd+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
],
[{
label: '⌘, ⌘/',
ariaLabel: 'Command+, Command+/',
@@ -91,6 +97,7 @@ suite('keyboardMapper - MAC fallback', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -105,7 +112,7 @@ suite('keyboardMapper - MAC fallback', () => {
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -129,7 +136,7 @@ suite('keyboardMapper - LINUX fallback', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z', null],
dispatchParts: ['ctrl+Z'],
}]
);
});
@@ -153,6 +160,7 @@ suite('keyboardMapper - LINUX fallback', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -167,16 +175,17 @@ suite('keyboardMapper - LINUX fallback', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z', null],
dispatchParts: ['ctrl+Z'],
}
);
});
test('resolveUserBinding Ctrl+[Comma] Ctrl+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
],
[{
label: 'Ctrl+, Ctrl+/',
ariaLabel: 'Control+, Control+/',
@@ -191,9 +200,9 @@ suite('keyboardMapper - LINUX fallback', () => {
test('resolveUserBinding Ctrl+[Comma]', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
null,
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
],
[{
label: 'Ctrl+,',
ariaLabel: 'Control+,',
@@ -201,7 +210,7 @@ suite('keyboardMapper - LINUX fallback', () => {
userSettingsLabel: 'ctrl+,',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+,', null],
dispatchParts: ['ctrl+,'],
}]
);
});
@@ -210,6 +219,7 @@ suite('keyboardMapper - LINUX fallback', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -224,7 +234,7 @@ suite('keyboardMapper - LINUX fallback', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { KeyChord, KeyCode, KeyMod, SimpleKeybinding, createKeybinding } from 'vs/base/common/keyCodes';
import { KeyChord, KeyCode, KeyMod, SimpleKeybinding, createKeybinding, createSimpleKeybinding } from 'vs/base/common/keyCodes';
import { UserSettingsLabelProvider } from 'vs/base/common/keybindingLabels';
import { OperatingSystem } from 'vs/base/common/platform';
import { ScanCode, ScanCodeBinding, ScanCodeUtils } from 'vs/base/common/scanCode';
@@ -65,7 +65,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+a',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyA]', null],
dispatchParts: ['meta+[KeyA]'],
}]
);
});
@@ -80,7 +80,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+b',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyB]', null],
dispatchParts: ['meta+[KeyB]'],
}]
);
});
@@ -95,7 +95,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyY]', null],
dispatchParts: ['meta+[KeyY]'],
}]
);
});
@@ -104,6 +104,7 @@ suite('keyboardMapper - MAC de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -118,7 +119,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyY]', null],
dispatchParts: ['meta+[KeyY]'],
}
);
});
@@ -133,7 +134,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'ctrl+alt+cmd+6',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+meta+[Digit6]', null],
dispatchParts: ['ctrl+alt+meta+[Digit6]'],
}]
);
});
@@ -142,6 +143,7 @@ suite('keyboardMapper - MAC de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -156,7 +158,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+[BracketRight]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['meta+[BracketRight]', null],
dispatchParts: ['meta+[BracketRight]'],
}
);
});
@@ -171,7 +173,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'ctrl+alt+9',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+[Digit9]', null],
dispatchParts: ['ctrl+alt+[Digit9]'],
}]
);
});
@@ -186,7 +188,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'shift+cmd+7',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['shift+meta+[Digit7]', null],
dispatchParts: ['shift+meta+[Digit7]'],
}]
);
});
@@ -201,7 +203,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'shift+cmd+[Minus]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['shift+meta+[Minus]', null],
dispatchParts: ['shift+meta+[Minus]'],
}]
);
});
@@ -246,7 +248,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+down',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[ArrowDown]', null],
dispatchParts: ['meta+[ArrowDown]'],
}]
);
});
@@ -261,7 +263,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+numpad0',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Numpad0]', null],
dispatchParts: ['meta+[Numpad0]'],
}]
);
});
@@ -276,7 +278,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Home]', null],
dispatchParts: ['meta+[Home]'],
}]
);
});
@@ -285,6 +287,7 @@ suite('keyboardMapper - MAC de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -299,16 +302,22 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Home]', null],
dispatchParts: ['meta+[Home]'],
}
);
});
test('resolveUserBinding empty', () => {
assertResolveUserBinding(mapper, [], []);
});
test('resolveUserBinding Cmd+[Comma] Cmd+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
[
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
],
[{
label: '⌘, ⇧⌘7',
ariaLabel: 'Command+, Shift+Command+7',
@@ -325,6 +334,7 @@ suite('keyboardMapper - MAC de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -339,7 +349,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -348,6 +358,7 @@ suite('keyboardMapper - MAC de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -362,7 +373,7 @@ suite('keyboardMapper - MAC de_ch', () => {
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -384,8 +395,10 @@ suite('keyboardMapper - MAC en_us', () => {
test('resolveUserBinding Cmd+[Comma] Cmd+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
[
new ScanCodeBinding(false, false, false, true, ScanCode.Comma),
new SimpleKeybinding(false, false, false, true, KeyCode.US_SLASH),
],
[{
label: '⌘, ⌘/',
ariaLabel: 'Command+, Command+/',
@@ -402,6 +415,7 @@ suite('keyboardMapper - MAC en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -416,7 +430,7 @@ suite('keyboardMapper - MAC en_us', () => {
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -425,6 +439,7 @@ suite('keyboardMapper - MAC en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -439,7 +454,7 @@ suite('keyboardMapper - MAC en_us', () => {
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -491,7 +506,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+a',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyA]', null],
dispatchParts: ['ctrl+[KeyA]'],
}]
);
});
@@ -506,7 +521,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyY]', null],
dispatchParts: ['ctrl+[KeyY]'],
}]
);
});
@@ -515,6 +530,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -529,7 +545,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyY]', null],
dispatchParts: ['ctrl+[KeyY]'],
}
);
});
@@ -545,6 +561,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -559,7 +576,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+[BracketRight]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]', null],
dispatchParts: ['ctrl+[BracketRight]'],
}
);
});
@@ -574,7 +591,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+alt+0',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+[Digit0]', null],
dispatchParts: ['ctrl+alt+[Digit0]'],
}, {
label: 'Ctrl+Alt+$',
ariaLabel: 'Control+Alt+$',
@@ -582,7 +599,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+alt+[Backslash]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+alt+[Backslash]', null],
dispatchParts: ['ctrl+alt+[Backslash]'],
}]
);
});
@@ -597,7 +614,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+shift+7',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Digit7]', null],
dispatchParts: ['ctrl+shift+[Digit7]'],
}]
);
});
@@ -612,7 +629,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+shift+[Minus]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+shift+[Minus]', null],
dispatchParts: ['ctrl+shift+[Minus]'],
}]
);
});
@@ -649,7 +666,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+down',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[ArrowDown]', null],
dispatchParts: ['ctrl+[ArrowDown]'],
}]
);
});
@@ -664,7 +681,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+numpad0',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Numpad0]', null],
dispatchParts: ['ctrl+[Numpad0]'],
}]
);
});
@@ -679,7 +696,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]', null],
dispatchParts: ['ctrl+[Home]'],
}]
);
});
@@ -688,6 +705,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -702,7 +720,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]', null],
dispatchParts: ['ctrl+[Home]'],
}
);
});
@@ -711,6 +729,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -725,16 +744,17 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+x',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyX]', null],
dispatchParts: ['ctrl+[KeyX]'],
}
);
});
test('resolveUserBinding Ctrl+[Comma] Ctrl+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
],
[{
label: 'Ctrl+, Ctrl+Shift+7',
ariaLabel: 'Control+, Control+Shift+7',
@@ -751,6 +771,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -765,7 +786,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -774,6 +795,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -788,7 +810,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -821,7 +843,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+a',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyA]', null],
dispatchParts: ['ctrl+[KeyA]'],
}]
);
});
@@ -836,7 +858,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyZ]', null],
dispatchParts: ['ctrl+[KeyZ]'],
}]
);
});
@@ -845,6 +867,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -859,7 +882,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyZ]', null],
dispatchParts: ['ctrl+[KeyZ]'],
}
);
});
@@ -874,7 +897,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+]',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]', null],
dispatchParts: ['ctrl+[BracketRight]'],
}]
);
});
@@ -883,6 +906,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -897,7 +921,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+]',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]', null],
dispatchParts: ['ctrl+[BracketRight]'],
}
);
});
@@ -912,7 +936,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'shift+]',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['shift+[BracketRight]', null],
dispatchParts: ['shift+[BracketRight]'],
}]
);
});
@@ -927,7 +951,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+/',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Slash]', null],
dispatchParts: ['ctrl+[Slash]'],
}]
);
});
@@ -942,7 +966,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+shift+/',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Slash]', null],
dispatchParts: ['ctrl+shift+[Slash]'],
}]
);
});
@@ -987,7 +1011,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+down',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[ArrowDown]', null],
dispatchParts: ['ctrl+[ArrowDown]'],
}]
);
});
@@ -1002,7 +1026,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+numpad0',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Numpad0]', null],
dispatchParts: ['ctrl+[Numpad0]'],
}]
);
});
@@ -1017,7 +1041,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]', null],
dispatchParts: ['ctrl+[Home]'],
}]
);
});
@@ -1026,6 +1050,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -1040,7 +1065,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]', null],
dispatchParts: ['ctrl+[Home]'],
}
);
});
@@ -1055,7 +1080,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+shift+,',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Comma]', null],
dispatchParts: ['ctrl+shift+[Comma]'],
}, {
label: 'Ctrl+<',
ariaLabel: 'Control+<',
@@ -1063,7 +1088,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+[IntlBackslash]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+[IntlBackslash]', null],
dispatchParts: ['ctrl+[IntlBackslash]'],
}]
);
});
@@ -1078,7 +1103,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+enter',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Enter]', null],
dispatchParts: ['ctrl+[Enter]'],
}]
);
});
@@ -1087,6 +1112,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -1101,16 +1127,17 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+enter',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Enter]', null],
dispatchParts: ['ctrl+[Enter]'],
}
);
});
test('resolveUserBinding Ctrl+[Comma] Ctrl+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
],
[{
label: 'Ctrl+, Ctrl+/',
ariaLabel: 'Control+, Control+/',
@@ -1125,9 +1152,9 @@ suite('keyboardMapper - LINUX en_us', () => {
test('resolveUserBinding Ctrl+[Comma]', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
null,
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma)
],
[{
label: 'Ctrl+,',
ariaLabel: 'Control+,',
@@ -1135,7 +1162,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+,',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Comma]', null],
dispatchParts: ['ctrl+[Comma]'],
}]
);
});
@@ -1144,6 +1171,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -1158,7 +1186,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -1167,6 +1195,7 @@ suite('keyboardMapper - LINUX en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -1181,7 +1210,7 @@ suite('keyboardMapper - LINUX en_us', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -1202,6 +1231,7 @@ suite('keyboardMapper', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -1216,7 +1246,7 @@ suite('keyboardMapper', () => {
userSettingsLabel: 'ctrl+`',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Backquote]', null],
dispatchParts: ['ctrl+[Backquote]'],
}
);
});
@@ -1228,6 +1258,7 @@ suite('keyboardMapper', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -1242,7 +1273,7 @@ suite('keyboardMapper', () => {
userSettingsLabel: userSettingsLabel,
isWYSIWYG: true,
isChord: false,
dispatchParts: [dispatch, null],
dispatchParts: [dispatch],
}
);
}
@@ -1267,6 +1298,7 @@ suite('keyboardMapper', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
@@ -1281,7 +1313,7 @@ suite('keyboardMapper', () => {
userSettingsLabel: userSettingsLabel,
isWYSIWYG: true,
isChord: false,
dispatchParts: [dispatch, null],
dispatchParts: [dispatch],
}
);
}
@@ -1339,7 +1371,7 @@ suite('keyboardMapper - LINUX ru', () => {
userSettingsLabel: 'ctrl+s',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyS]', null],
dispatchParts: ['ctrl+[KeyS]'],
}]
);
});
@@ -1362,6 +1394,7 @@ suite('keyboardMapper - LINUX en_uk', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: true,
@@ -1376,7 +1409,7 @@ suite('keyboardMapper - LINUX en_uk', () => {
userSettingsLabel: 'ctrl+alt+[Minus]',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+alt+[Minus]', null],
dispatchParts: ['ctrl+alt+[Minus]'],
}
);
});
@@ -1409,7 +1442,7 @@ suite('keyboardMapper - MAC zh_hant', () => {
userSettingsLabel: 'cmd+c',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyC]', null],
dispatchParts: ['meta+[KeyC]'],
}]
);
});
@@ -1425,17 +1458,17 @@ function _assertKeybindingTranslation(mapper: MacLinuxKeyboardMapper, OS: Operat
expected = [];
}
const runtimeKeybinding = createKeybinding(kb, OS);
const runtimeKeybinding = createSimpleKeybinding(kb, OS);
const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding!, OS).getUserSettingsLabel();
const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding.toChord(), OS).getUserSettingsLabel();
const actualHardwareKeypresses = mapper.simpleKeybindingToScanCodeBinding(<SimpleKeybinding>runtimeKeybinding);
const actualHardwareKeypresses = mapper.simpleKeybindingToScanCodeBinding(runtimeKeybinding);
if (actualHardwareKeypresses.length === 0) {
assert.deepEqual([], expected, `simpleKeybindingToHardwareKeypress -- "${keybindingLabel}" -- actual: "[]" -- expected: "${expected}"`);
return;
}
const actual = actualHardwareKeypresses
.map(k => UserSettingsLabelProvider.toLabel(k, ScanCodeUtils.toString(k.scanCode), null, null, OS));
.map(k => UserSettingsLabelProvider.toLabel(OS, [k], (keybinding) => ScanCodeUtils.toString(keybinding.scanCode)));
assert.deepEqual(actual, expected, `simpleKeybindingToHardwareKeypress -- "${keybindingLabel}" -- actual: "${actual}" -- expected: "${expected}"`);
}

View File

@@ -44,7 +44,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+a',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+A', null],
dispatchParts: ['ctrl+A'],
}]
);
});
@@ -60,7 +60,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z', null],
dispatchParts: ['ctrl+Z'],
}]
);
});
@@ -69,6 +69,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -83,7 +84,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+z',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z', null],
dispatchParts: ['ctrl+Z'],
}
);
});
@@ -99,7 +100,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+oem_6',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+]', null],
dispatchParts: ['ctrl+]'],
}]
);
});
@@ -108,6 +109,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -122,7 +124,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+oem_6',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+]', null],
dispatchParts: ['ctrl+]'],
}
);
});
@@ -138,7 +140,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'shift+oem_6',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['shift+]', null],
dispatchParts: ['shift+]'],
}]
);
});
@@ -154,7 +156,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+oem_2',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+/', null],
dispatchParts: ['ctrl+/'],
}]
);
});
@@ -170,7 +172,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+shift+oem_2',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+shift+/', null],
dispatchParts: ['ctrl+shift+/'],
}]
);
});
@@ -210,7 +212,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+down',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+DownArrow', null],
dispatchParts: ['ctrl+DownArrow'],
}]
);
});
@@ -226,7 +228,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+numpad0',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+NumPad0', null],
dispatchParts: ['ctrl+NumPad0'],
}]
);
});
@@ -242,7 +244,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Home', null],
dispatchParts: ['ctrl+Home'],
}]
);
});
@@ -251,6 +253,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -265,16 +268,21 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+home',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Home', null],
dispatchParts: ['ctrl+Home'],
}
);
});
test('resolveUserBinding empty', () => {
assertResolveUserBinding(mapper, [], []);
});
test('resolveUserBinding Ctrl+[Comma] Ctrl+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
],
[{
label: 'Ctrl+, Ctrl+§',
ariaLabel: 'Control+, Control+§',
@@ -291,6 +299,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -305,7 +314,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -341,9 +350,10 @@ suite('keyboardMapper - WINDOWS en_us', () => {
test('resolveUserBinding Ctrl+[Comma] Ctrl+/', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
new SimpleKeybinding(true, false, false, false, KeyCode.US_SLASH),
],
[{
label: 'Ctrl+, Ctrl+/',
ariaLabel: 'Control+, Control+/',
@@ -358,9 +368,9 @@ suite('keyboardMapper - WINDOWS en_us', () => {
test('resolveUserBinding Ctrl+[Comma]', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
null!,
mapper, [
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
],
[{
label: 'Ctrl+,',
ariaLabel: 'Control+,',
@@ -368,7 +378,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
userSettingsLabel: 'ctrl+,',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+,', null],
dispatchParts: ['ctrl+,'],
}]
);
});
@@ -377,6 +387,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -391,7 +402,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null, null],
dispatchParts: [null],
}
);
});
@@ -413,6 +424,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -427,7 +439,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
userSettingsLabel: 'ctrl+abnt_c1',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+ABNT_C1', null],
dispatchParts: ['ctrl+ABNT_C1'],
}
);
});
@@ -436,6 +448,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: false,
altKey: false,
@@ -450,7 +463,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
userSettingsLabel: 'ctrl+abnt_c2',
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+ABNT_C2', null],
dispatchParts: ['ctrl+ABNT_C2'],
}
);
});
@@ -514,7 +527,7 @@ suite('keyboardMapper - misc', () => {
userSettingsLabel: 'ctrl+b',
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+B', null],
dispatchParts: ['ctrl+B'],
}]
);
});