Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -32,11 +32,11 @@ export interface IKeybindingEditingService {
_serviceBrand: ServiceIdentifier<any>;
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Thenable<void>;
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void>;
removeKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void>;
removeKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void>;
resetKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void>;
resetKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void>;
}
export class KeybindingsEditingService extends Disposable implements IKeybindingEditingService {
@@ -47,29 +47,29 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private resource: URI = URI.file(this.environmentService.appKeybindingsPath);
constructor(
@ITextModelService private textModelResolverService: ITextModelService,
@ITextFileService private textFileService: ITextFileService,
@IFileService private fileService: IFileService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService
@ITextModelService private readonly textModelResolverService: ITextModelService,
@ITextFileService private readonly textFileService: ITextFileService,
@IFileService private readonly fileService: IFileService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IEnvironmentService private readonly environmentService: IEnvironmentService
) {
super();
this.queue = new Queue<void>();
}
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Thenable<void> {
editKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.queue.queue(() => this.doEditKeybinding(key, keybindingItem)); // queue up writes to prevent race conditions
}
resetKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void> {
resetKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.queue.queue(() => this.doResetKeybinding(keybindingItem)); // queue up writes to prevent race conditions
}
removeKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void> {
removeKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.queue.queue(() => this.doRemoveKeybinding(keybindingItem)); // queue up writes to prevent race conditions
}
private doEditKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Thenable<void> {
private doEditKeybinding(key: string, keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.resolveAndValidate()
.then(reference => {
const model = reference.object.textEditorModel;
@@ -83,7 +83,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
});
}
private doRemoveKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void> {
private doRemoveKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.resolveAndValidate()
.then(reference => {
const model = reference.object.textEditorModel;
@@ -96,7 +96,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
});
}
private doResetKeybinding(keybindingItem: ResolvedKeybindingItem): Thenable<void> {
private doResetKeybinding(keybindingItem: ResolvedKeybindingItem): Promise<void> {
return this.resolveAndValidate()
.then(reference => {
const model = reference.object.textEditorModel;
@@ -108,7 +108,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
});
}
private save(): Thenable<any> {
private save(): Promise<any> {
return this.textFileService.save(this.resource);
}
@@ -130,7 +130,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
const userKeybindingEntries = <IUserFriendlyKeybinding[]>json.parse(model.getValue());
const userKeybindingEntryIndex = this.findUserKeybindingEntryIndex(keybindingItem, userKeybindingEntries);
if (userKeybindingEntryIndex !== -1) {
this.applyEditsToBuffer(setProperty(model.getValue(), [userKeybindingEntryIndex], void 0, { tabSize, insertSpaces, eol })[0], model);
this.applyEditsToBuffer(setProperty(model.getValue(), [userKeybindingEntryIndex], undefined, { tabSize, insertSpaces, eol })[0], model);
}
}
@@ -146,7 +146,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
const userKeybindingEntries = <IUserFriendlyKeybinding[]>json.parse(model.getValue());
const indices = this.findUnassignedDefaultKeybindingEntryIndex(keybindingItem, userKeybindingEntries).reverse();
for (const index of indices) {
this.applyEditsToBuffer(setProperty(model.getValue(), [index], void 0, { tabSize, insertSpaces, eol })[0], model);
this.applyEditsToBuffer(setProperty(model.getValue(), [index], undefined, { tabSize, insertSpaces, eol })[0], model);
}
}
@@ -197,16 +197,16 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
}
private resolveModelReference(): Thenable<IReference<ITextEditorModel>> {
private resolveModelReference(): Promise<IReference<ITextEditorModel>> {
return this.fileService.existsFile(this.resource)
.then(exists => {
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
const result: Thenable<any> = exists ? Promise.resolve(null) : this.fileService.updateContent(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
const result: Promise<any> = exists ? Promise.resolve(null) : this.fileService.updateContent(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
return result.then(() => this.textModelResolverService.createModelReference(this.resource));
});
}
private resolveAndValidate(): Thenable<IReference<ITextEditorModel>> {
private resolveAndValidate(): Promise<IReference<ITextEditorModel>> {
// Target cannot be dirty if not writing into buffer
if (this.textFileService.isDirty(this.resource)) {

View File

@@ -29,13 +29,14 @@ export class CachedKeyboardMapper implements IKeyboardMapper {
}
public resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[] {
let hashCode = keybinding.getHashCode();
if (!this._cache.has(hashCode)) {
let r = this._actual.resolveKeybinding(keybinding);
const hashCode = keybinding.getHashCode();
const resolved = this._cache.get(hashCode);
if (!resolved) {
const r = this._actual.resolveKeybinding(keybinding);
this._cache.set(hashCode, r);
return r;
}
return this._cache.get(hashCode);
return resolved;
}
public resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding {

View File

@@ -445,11 +445,11 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
/**
* UI label for a ScanCode.
*/
private readonly _scanCodeToLabel: (string | null)[] = [];
private readonly _scanCodeToLabel: Array<string | null> = [];
/**
* Dispatching string for a ScanCode.
*/
private readonly _scanCodeToDispatch: (string | null)[] = [];
private readonly _scanCodeToDispatch: Array<string | null> = [];
constructor(isUSStandard: boolean, rawMappings: IMacLinuxKeyboardMapping, OS: OperatingSystem) {
this._isUSStandard = isUSStandard;
@@ -800,7 +800,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
for (let i = 0, len = kbCombos.length; i < len; i++) {
const kbCombo = kbCombos[i];
// find out the priority of this scan code for this key code
let colPriority = '-';
let colPriority: string;
const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(kbCombo);
if (scanCodeCombos.length === 1) {

View File

@@ -303,7 +303,7 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
public readonly isUSStandard: boolean;
private readonly _codeInfo: IScanCodeMapping[];
private readonly _scanCodeToKeyCode: KeyCode[];
private readonly _keyCodeToLabel: (string | null)[] = [];
private readonly _keyCodeToLabel: Array<string | null> = [];
private readonly _keyCodeExists: boolean[];
constructor(isUSStandard: boolean, rawMappings: IWindowsKeyboardMapping) {
@@ -460,9 +460,8 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
const mapping = this._codeInfo[scanCode];
const strCode = ScanCodeUtils.toString(scanCode);
let mods = [0b000, 0b010, 0b101, 0b111];
for (let modIndex = 0; modIndex < mods.length; modIndex++) {
const mod = mods[modIndex];
const mods = [0b000, 0b010, 0b101, 0b111];
for (const mod of mods) {
const ctrlKey = (mod & 0b001) ? true : false;
const shiftKey = (mod & 0b010) ? true : false;
const altKey = (mod & 0b100) ? true : false;

View File

@@ -24,7 +24,7 @@ import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/c
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
import { IKeybindingEvent, IKeyboardEvent, IUserFriendlyKeybinding, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
import { IKeybindingItem, IKeybindingRule2, KeybindingRuleSource, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IKeybindingItem, IKeybindingRule2, KeybindingWeight, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -37,6 +37,7 @@ import { CachedKeyboardMapper, IKeyboardMapper } from 'vs/workbench/services/key
import { MacLinuxFallbackKeyboardMapper } from 'vs/workbench/services/keybinding/common/macLinuxFallbackKeyboardMapper';
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';
export class KeyboardMapperFactory {
public static readonly INSTANCE = new KeyboardMapperFactory();
@@ -46,7 +47,7 @@ export class KeyboardMapperFactory {
private _keyboardMapper: IKeyboardMapper | null;
private _initialized: boolean;
private readonly _onDidChangeKeyboardMapper: Emitter<void> = new Emitter<void>();
private readonly _onDidChangeKeyboardMapper = new Emitter<void>();
public readonly onDidChangeKeyboardMapper: Event<void> = this._onDidChangeKeyboardMapper.event;
private constructor() {
@@ -155,6 +156,7 @@ export class KeyboardMapperFactory {
interface ContributedKeyBinding {
command: string;
args?: any;
key: string;
when?: string;
mac?: string;
@@ -206,6 +208,9 @@ let keybindingType: IJSONSchema = {
description: nls.localize('vscode.extension.contributes.keybindings.command', 'Identifier of the command to run when keybinding is triggered.'),
type: 'string'
},
args: {
description: nls.localize('vscode.extension.contributes.keybindings.args', "Arguments to pass to the command to execute.")
},
key: {
description: nls.localize('vscode.extension.contributes.keybindings.key', 'Key or key sequence (separate keys with plus-sign and sequences with space, e.g Ctrl+O and Ctrl+L L for a chord).'),
type: 'string'
@@ -225,19 +230,23 @@ let keybindingType: IJSONSchema = {
when: {
description: nls.localize('vscode.extension.contributes.keybindings.when', 'Condition when the key is active.'),
type: 'string'
}
},
}
};
let keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedKeyBinding | ContributedKeyBinding[]>('keybindings', [], {
description: nls.localize('vscode.extension.contributes.keybindings', "Contributes keybindings."),
oneOf: [
keybindingType,
{
type: 'array',
items: keybindingType
}
]
const keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedKeyBinding | ContributedKeyBinding[]>({
isDynamic: true,
extensionPoint: 'keybindings',
jsonSchema: {
description: nls.localize('vscode.extension.contributes.keybindings', "Contributes keybindings."),
oneOf: [
keybindingType,
{
type: 'array',
items: keybindingType
}
]
}
});
export const enum DispatchConfig {
@@ -266,7 +275,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
@INotificationService notificationService: INotificationService,
@IEnvironmentService environmentService: IEnvironmentService,
@IStatusbarService statusBarService: IStatusbarService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService configurationService: IConfigurationService,
@IWindowService private readonly windowService: IWindowService
) {
super(contextKeyService, commandService, telemetryService, notificationService, statusBarService);
@@ -294,15 +304,14 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
this.userKeybindings = this._register(new ConfigWatcher(environmentService.appKeybindingsPath, { defaultConfig: [], onError: error => onUnexpectedError(error) }));
keybindingsExtPoint.setHandler((extensions) => {
let commandAdded = false;
let keybindings: IKeybindingRule2[] = [];
for (let extension of extensions) {
commandAdded = this._handleKeybindingsExtensionPointUser(extension.description.isBuiltin, extension.value, extension.collector) || commandAdded;
this._handleKeybindingsExtensionPointUser(extension.description.isBuiltin, extension.value, extension.collector, keybindings);
}
if (commandAdded) {
this.updateResolver({ source: KeybindingSource.Default });
}
KeybindingsRegistry.setExtensionKeybindings(keybindings);
this.updateResolver({ source: KeybindingSource.Default });
});
this._register(this.userKeybindings.onDidUpdateConfiguration(event => this.updateResolver({
@@ -367,13 +376,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}
protected _documentHasFocus(): boolean {
return document.hasFocus();
// it is possible that the document has lost focus, but the
// window is still focused, e.g. when a <webview> element
// has focus
return this.windowService.hasFocus;
}
private _resolveKeybindingItems(items: IKeybindingItem[], isDefault: boolean): ResolvedKeybindingItem[] {
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
for (const item of items) {
const when = (item.when ? item.when.normalize() : null);
const keybinding = item.keybinding;
if (!keybinding) {
@@ -381,8 +392,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
result[resultLen++] = new ResolvedKeybindingItem(null, item.command, item.commandArgs, when, isDefault);
} else {
const resolvedKeybindings = this.resolveKeybinding(keybinding);
for (let j = 0; j < resolvedKeybindings.length; j++) {
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybindings[j], item.command, item.commandArgs, when, isDefault);
for (const resolvedKeybinding of resolvedKeybindings) {
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
}
}
}
@@ -392,8 +403,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
private _resolveUserKeybindingItems(items: IUserKeybindingItem[], isDefault: boolean): ResolvedKeybindingItem[] {
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
for (const item of items) {
const when = (item.when ? item.when.normalize() : null);
const firstPart = item.firstPart;
const chordPart = item.chordPart;
@@ -402,8 +412,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
result[resultLen++] = new ResolvedKeybindingItem(null, item.command, item.commandArgs, when, isDefault);
} else {
const resolvedKeybindings = this._keyboardMapper.resolveUserBinding(firstPart, chordPart);
for (let j = 0; j < resolvedKeybindings.length; j++) {
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybindings[j], item.command, item.commandArgs, when, isDefault);
for (const resolvedKeybinding of resolvedKeybindings) {
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
}
}
}
@@ -442,28 +452,24 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return this._keyboardMapper.resolveUserBinding(firstPart, chordPart);
}
private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings: ContributedKeyBinding | ContributedKeyBinding[], collector: ExtensionMessageCollector): boolean {
private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings: ContributedKeyBinding | ContributedKeyBinding[], collector: ExtensionMessageCollector, result: IKeybindingRule2[]): void {
if (isContributedKeyBindingsArray(keybindings)) {
let commandAdded = false;
for (let i = 0, len = keybindings.length; i < len; i++) {
commandAdded = this._handleKeybinding(isBuiltin, i + 1, keybindings[i], collector) || commandAdded;
this._handleKeybinding(isBuiltin, i + 1, keybindings[i], collector, result);
}
return commandAdded;
} else {
return this._handleKeybinding(isBuiltin, 1, keybindings, collector);
this._handleKeybinding(isBuiltin, 1, keybindings, collector, result);
}
}
private _handleKeybinding(isBuiltin: boolean, idx: number, keybindings: ContributedKeyBinding, collector: ExtensionMessageCollector): boolean {
private _handleKeybinding(isBuiltin: boolean, idx: number, keybindings: ContributedKeyBinding, collector: ExtensionMessageCollector, result: IKeybindingRule2[]): void {
let rejects: string[] = [];
let commandAdded = false;
if (isValidContributedKeyBinding(keybindings, rejects)) {
let rule = this._asCommandRule(isBuiltin, idx++, keybindings);
if (rule) {
KeybindingsRegistry.registerKeybindingRule2(rule, KeybindingRuleSource.Extension);
commandAdded = true;
result.push(rule);
}
}
@@ -475,13 +481,11 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
rejects.join('\n')
));
}
return commandAdded;
}
private _asCommandRule(isBuiltin: boolean, idx: number, binding: ContributedKeyBinding): IKeybindingRule2 | undefined {
let { command, when, key, mac, linux, win } = binding;
let { command, args, when, key, mac, linux, win } = binding;
let weight: number;
if (isBuiltin) {
@@ -492,6 +496,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
let desc: IKeybindingRule2 = {
id: command,
args,
when: ContextKeyExpr.deserialize(when),
weight: weight,
primary: KeybindingParser.parseKeybinding(key, OS),

View File

@@ -111,11 +111,11 @@ suite('KeybindingsEditing', () => {
teardown(() => {
return new Promise<void>((c, e) => {
if (testDir) {
extfs.del(testDir, os.tmpdir(), () => c(null), () => c(null));
extfs.del(testDir, os.tmpdir(), () => c(undefined), () => c(undefined));
} else {
c(null);
c(undefined);
}
}).then(() => testDir = null);
}).then(() => testDir = null!);
});
test('errors cases - parse errors', () => {
@@ -247,10 +247,10 @@ suite('KeybindingsEditing', () => {
function aResolvedKeybindingItem({ command, when, isDefault, firstPart, chordPart }: { command?: string, when?: string, isDefault?: boolean, firstPart?: { keyCode: KeyCode, modifiers?: Modifiers }, chordPart?: { keyCode: KeyCode, modifiers?: Modifiers } }): ResolvedKeybindingItem {
const aSimpleKeybinding = function (part: { keyCode: KeyCode, modifiers?: Modifiers }): SimpleKeybinding {
const { ctrlKey, shiftKey, altKey, metaKey } = part.modifiers || { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false };
return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, part.keyCode);
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 === void 0 ? true : isDefault);
return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === undefined ? true : isDefault);
}
});

View File

@@ -16,7 +16,7 @@ suite('keybindingIO', () => {
test('serialize/deserialize', () => {
function testOneSerialization(keybinding: number, expected: string, msg: string, OS: OperatingSystem): void {
let usLayoutResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS);
let usLayoutResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS);
let actualSerialized = usLayoutResolvedKeybinding.getUserSettingsLabel();
assert.equal(actualSerialized, expected, expected + ' - ' + msg);
}

View File

@@ -34,8 +34,8 @@ function toIResolvedKeybinding(kb: ResolvedKeybinding): IResolvedKeybinding {
};
}
export function assertResolveKeybinding(mapper: IKeyboardMapper, keybinding: Keybinding, expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveKeybinding(keybinding).map(toIResolvedKeybinding);
export function assertResolveKeybinding(mapper: IKeyboardMapper, keybinding: Keybinding | null, expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveKeybinding(keybinding!).map(toIResolvedKeybinding);
assert.deepEqual(actual, expected);
}
@@ -44,7 +44,7 @@ export function assertResolveKeyboardEvent(mapper: IKeyboardMapper, keyboardEven
assert.deepEqual(actual, expected);
}
export function assertResolveUserBinding(mapper: IKeyboardMapper, firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding, expected: IResolvedKeybinding[]): void {
export function assertResolveUserBinding(mapper: IKeyboardMapper, firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding | null, expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveUserBinding(firstPart, chordPart).map(toIResolvedKeybinding);
assert.deepEqual(actual, expected);
}

View File

@@ -14,7 +14,7 @@ suite('keyboardMapper - MAC fallback', () => {
let mapper = new MacLinuxFallbackKeyboardMapper(OperatingSystem.Macintosh);
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected);
}
test('resolveKeybinding Cmd+Z', () => {
@@ -56,7 +56,7 @@ suite('keyboardMapper - MAC fallback', () => {
altKey: false,
metaKey: true,
keyCode: KeyCode.KEY_Z,
code: null
code: null!
},
{
label: '⌘Z',
@@ -96,7 +96,7 @@ suite('keyboardMapper - MAC fallback', () => {
altKey: false,
metaKey: true,
keyCode: KeyCode.Meta,
code: null
code: null!
},
{
label: '⌘',
@@ -116,7 +116,7 @@ suite('keyboardMapper - LINUX fallback', () => {
let mapper = new MacLinuxFallbackKeyboardMapper(OperatingSystem.Linux);
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected);
}
test('resolveKeybinding Ctrl+Z', () => {
@@ -158,7 +158,7 @@ suite('keyboardMapper - LINUX fallback', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.KEY_Z,
code: null
code: null!
},
{
label: 'Ctrl+Z',
@@ -215,7 +215,7 @@ suite('keyboardMapper - LINUX fallback', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
code: null!
},
{
label: 'Ctrl+',

View File

@@ -37,7 +37,7 @@ suite('keyboardMapper - MAC de_ch', () => {
}
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected);
}
test('kb => hw', () => {
@@ -463,7 +463,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
}
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected);
}
test('kb => hw', () => {
@@ -808,7 +808,7 @@ suite('keyboardMapper - LINUX en_us', () => {
});
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected);
}
test('resolveKeybinding Ctrl+A', () => {
@@ -1224,7 +1224,7 @@ suite('keyboardMapper', () => {
test('issue #24064: NumLock/NumPad keys stopped working in 1.11 on Linux', () => {
let mapper = new MacLinuxKeyboardMapper(false, {}, OperatingSystem.Linux);
function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string, userSettingsLabel: string, dispatch: string): void {
function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string | null, userSettingsLabel: string, dispatch: string): void {
assertResolveKeyboardEvent(
mapper,
{
@@ -1251,7 +1251,7 @@ suite('keyboardMapper', () => {
assertNumpadKeyboardEvent(KeyCode.DownArrow, 'Numpad2', 'DownArrow', 'Down', 'down', '[ArrowDown]');
assertNumpadKeyboardEvent(KeyCode.PageDown, 'Numpad3', 'PageDown', 'PageDown', 'pagedown', '[PageDown]');
assertNumpadKeyboardEvent(KeyCode.LeftArrow, 'Numpad4', 'LeftArrow', 'Left', 'left', '[ArrowLeft]');
assertNumpadKeyboardEvent(KeyCode.Unknown, 'Numpad5', 'NumPad5', null, 'numpad5', '[Numpad5]');
assertNumpadKeyboardEvent(KeyCode.Unknown, 'Numpad5', 'NumPad5', null!, 'numpad5', '[Numpad5]');
assertNumpadKeyboardEvent(KeyCode.RightArrow, 'Numpad6', 'RightArrow', 'Right', 'right', '[ArrowRight]');
assertNumpadKeyboardEvent(KeyCode.Home, 'Numpad7', 'Home', 'Home', 'home', '[Home]');
assertNumpadKeyboardEvent(KeyCode.UpArrow, 'Numpad8', 'UpArrow', 'Up', 'up', '[ArrowUp]');
@@ -1326,7 +1326,7 @@ suite('keyboardMapper - LINUX ru', () => {
});
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected);
}
test('resolveKeybinding Ctrl+S', () => {
@@ -1396,7 +1396,7 @@ suite('keyboardMapper - MAC zh_hant', () => {
});
function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected);
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected);
}
test('issue #28237 resolveKeybinding Cmd+C', () => {
@@ -1427,7 +1427,7 @@ function _assertKeybindingTranslation(mapper: MacLinuxKeyboardMapper, OS: Operat
const runtimeKeybinding = createKeybinding(kb, OS);
const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding, OS).getUserSettingsLabel();
const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding!, OS).getUserSettingsLabel();
const actualHardwareKeypresses = mapper.simpleKeybindingToScanCodeBinding(<SimpleKeybinding>runtimeKeybinding);
if (actualHardwareKeypresses.length === 0) {

View File

@@ -17,7 +17,8 @@ async function createKeyboardMapper(isUSStandard: boolean, file: string): Promis
}
function _assertResolveKeybinding(mapper: WindowsKeyboardMapper, k: number, expected: IResolvedKeybinding[]): void {
assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Windows), expected);
const keyBinding = createKeybinding(k, OperatingSystem.Windows);
assertResolveKeybinding(mapper, keyBinding!, expected);
}
suite('keyboardMapper - WINDOWS de_ch', () => {
@@ -73,7 +74,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.KEY_Z,
code: null
code: null!
},
{
label: 'Ctrl+Z',
@@ -112,7 +113,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.US_CLOSE_SQUARE_BRACKET,
code: null
code: null!
},
{
label: 'Ctrl+^',
@@ -255,7 +256,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.Home,
code: null
code: null!
},
{
label: 'Ctrl+Home',
@@ -295,7 +296,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
code: null!
},
{
label: 'Ctrl+',
@@ -359,7 +360,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
assertResolveUserBinding(
mapper,
new ScanCodeBinding(true, false, false, false, ScanCode.Comma),
null,
null!,
[{
label: 'Ctrl+,',
ariaLabel: 'Control+,',
@@ -381,7 +382,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
code: null!
},
{
label: 'Ctrl+',
@@ -417,7 +418,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.ABNT_C1,
code: null
code: null!
},
{
label: 'Ctrl+/',
@@ -440,7 +441,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
altKey: false,
metaKey: false,
keyCode: KeyCode.ABNT_C2,
code: null
code: null!
},
{
label: 'Ctrl+.',