Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 (#15681)

* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898

* Fixes and cleanup

* Distro

* Fix hygiene yarn

* delete no yarn lock changes file

* Fix hygiene

* Fix layer check

* Fix CI

* Skip lib checks

* Remove tests deleted in vs code

* Fix tests

* Distro

* Fix tests and add removed extension point

* Skip failing notebook tests for now

* Disable broken tests and cleanup build folder

* Update yarn.lock and fix smoke tests

* Bump sqlite

* fix contributed actions and file spacing

* Fix user data path

* Update yarn.locks

Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
Charles Gagnon
2021-06-17 08:17:11 -07:00
committed by GitHub
parent fdcb97c7f7
commit 3cb2f552a6
2582 changed files with 124827 additions and 87099 deletions

View File

@@ -14,7 +14,7 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { OS, OperatingSystem, isMacintosh } from 'vs/base/common/platform';
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 { ConfigurationScope, Extensions as ConfigExtensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
@@ -353,7 +353,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return JSON.stringify(info, null, '\t');
}
public customKeybindingsCount(): number {
public override customKeybindingsCount(): number {
return this.userKeybindings.keybindings.length;
}
@@ -578,7 +578,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return desc;
}
public getDefaultKeybindingsContent(): string {
public override getDefaultKeybindingsContent(): string {
const resolver = this._getResolver();
const defaultKeybindings = resolver.getDefaultKeybindings();
const boundCommands = resolver.getDefaultBoundCommands();
@@ -612,7 +612,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return '// ' + nls.localize('unboundCommands', "Here are other available commands: ") + '\n// - ' + pretty;
}
mightProducePrintableCharacter(event: IKeyboardEvent): boolean {
override mightProducePrintableCharacter(event: IKeyboardEvent): boolean {
if (event.ctrlKey || event.metaKey || event.altKey) {
// ignore ctrl/cmd/alt-combination but not shift-combinatios
return false;
@@ -677,6 +677,8 @@ class UserKeybindings extends Disposable {
super();
this._register(fileService.watch(dirname(keybindingsResource)));
// Also listen to the resource incase the resource is a symlink - https://github.com/microsoft/vscode/issues/118134
this._register(this.fileService.watch(this.keybindingsResource));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reload().then(changed => {
if (changed) {
this._onDidChange.fire();
@@ -802,7 +804,11 @@ function updateSchema(additionalContributions: readonly IJSONSchema[]) {
}
const argsSchema = commandDescription.args[0].schema;
const argsRequired = Array.isArray(argsSchema.required) && argsSchema.required.length > 0;
const argsRequired = (
(typeof commandDescription.args[0].isOptional !== 'undefined')
? (!commandDescription.args[0].isOptional)
: (Array.isArray(argsSchema.required) && argsSchema.required.length > 0)
);
const addition = {
'if': {
'properties': {
@@ -837,11 +843,12 @@ const keyboardConfiguration: IConfigurationNode = {
'title': nls.localize('keyboardConfigurationTitle', "Keyboard"),
'properties': {
'keyboard.dispatch': {
'type': 'string',
'enum': ['code', 'keyCode'],
'default': 'code',
'markdownDescription': nls.localize('dispatch', "Controls the dispatching logic for key presses to use either `code` (recommended) or `keyCode`."),
'included': OS === OperatingSystem.Macintosh || OS === OperatingSystem.Linux
scope: ConfigurationScope.APPLICATION,
type: 'string',
enum: ['code', 'keyCode'],
default: 'code',
markdownDescription: nls.localize('dispatch', "Controls the dispatching logic for key presses to use either `code` (recommended) or `keyCode`."),
included: OS === OperatingSystem.Macintosh || OS === OperatingSystem.Linux
}
}
};

View File

@@ -190,7 +190,7 @@ export class BrowserKeyboardMapperFactoryBase {
// return;
// }
// // the keyboard layout doesn't actually match the key event or the keymap from chromium
// the keyboard layout doesn't actually match the key event or the keymap from chromium
// this._notificationService.prompt(
// Severity.Info,
// nls.localize('missing.keyboardlayout', 'Fail to find matching keyboard layout'),
@@ -513,6 +513,7 @@ export class BrowserKeyboardLayoutService extends Disposable implements IKeyboar
private readonly layoutChangeListener = this._register(new MutableDisposable());
private readonly _factory: BrowserKeyboardMapperFactory;
private _keyboardLayoutMode: string;
constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@@ -525,6 +526,7 @@ export class BrowserKeyboardLayoutService extends Disposable implements IKeyboar
super();
const keyboardConfig = configurationService.getValue<{ layout: string }>('keyboard');
const layout = keyboardConfig.layout;
this._keyboardLayoutMode = layout ?? 'autodetect';
this._factory = new BrowserKeyboardMapperFactory(notificationService, storageService, commandService);
this.registerKeyboardListener();
@@ -538,6 +540,7 @@ export class BrowserKeyboardLayoutService extends Disposable implements IKeyboar
if (e.affectedKeys.indexOf('keyboard.layout') >= 0) {
const keyboardConfig = configurationService.getValue<{ layout: string }>('keyboard');
const layout = keyboardConfig.layout;
this._keyboardLayoutMode = layout;
if (layout === 'autodetect') {
this.registerKeyboardListener();
@@ -614,6 +617,10 @@ export class BrowserKeyboardLayoutService extends Disposable implements IKeyboar
}
public validateCurrentKeyboardMapping(keyboardEvent: IKeyboardEvent): void {
if (this._keyboardLayoutMode !== 'autodetect') {
return;
}
this._factory.validateCurrentKeyboardMapping(keyboardEvent);
}
}

View File

@@ -46,7 +46,7 @@ export class MacLinuxFallbackKeyboardMapper implements IKeyboardMapper {
private _scanCodeToKeyCode(scanCode: ScanCode): KeyCode {
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
if (immutableKeyCode !== -1) {
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
return immutableKeyCode;
}

View File

@@ -49,7 +49,7 @@ export class NativeResolvedKeybinding extends BaseResolvedKeybinding<ScanCodeBin
if (!binding) {
return true;
}
if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !== -1) {
if (IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode] !== KeyCode.DependsOnKbLayout) {
return true;
}
let a = this._mapper.getAriaLabelForScanCodeBinding(binding);
@@ -327,7 +327,7 @@ class ScanCodeKeyCodeMapper {
}
}
return -1;
return KeyCode.DependsOnKbLayout;
}
private _encodeScanCodeCombo(scanCodeCombo: ScanCodeCombo): number {
@@ -419,7 +419,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
// Handle immutable mappings
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
const keyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
if (keyCode !== -1) {
if (keyCode !== KeyCode.DependsOnKbLayout) {
_registerAllCombos(0, 0, 0, scanCode, keyCode);
this._scanCodeToLabel[scanCode] = KeyCodeUtils.toString(keyCode);
@@ -443,7 +443,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
if (scanCode === ScanCode.None) {
continue;
}
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
continue;
}
@@ -504,7 +504,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
if (scanCode === ScanCode.None) {
continue;
}
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
continue;
}
@@ -678,7 +678,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
result.push(`isUSStandard: ${this._isUSStandard}`);
result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
if (immutableSamples.indexOf(scanCode) === -1) {
continue;
}
@@ -703,7 +703,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
shiftKey: scanCodeCombo.shiftKey,
altKey: scanCodeCombo.altKey,
metaKey: false,
keyCode: -1,
keyCode: KeyCode.DependsOnKbLayout,
code: ScanCodeUtils.toString(scanCode)
});
@@ -852,13 +852,13 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode];
if (immutableKeyCode !== -1) {
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
return KeyCodeUtils.toUserSettingsUS(immutableKeyCode).toLowerCase();
}
// Check if this scanCode always maps to the same keyCode and back
let constantKeyCode: KeyCode = this._scanCodeKeyCodeMapper.guessStableKeyCode(binding.scanCode);
if (constantKeyCode !== -1) {
if (constantKeyCode !== KeyCode.DependsOnKbLayout) {
// Verify that this is a good key code that can be mapped back to the same scan code
let reverseBindings = this.simpleKeybindingToScanCodeBinding(new SimpleKeybinding(binding.ctrlKey, binding.shiftKey, binding.altKey, binding.metaKey, constantKeyCode));
for (let i = 0, len = reverseBindings.length; i < len; i++) {
@@ -902,7 +902,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[binding.scanCode];
if (immutableKeyCode !== -1) {
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
return this._getElectronLabelForKeyCode(immutableKeyCode);
}
@@ -935,7 +935,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
return null;
}
if (constantKeyCode !== -1) {
if (constantKeyCode !== KeyCode.DependsOnKbLayout) {
return this._getElectronLabelForKeyCode(constantKeyCode);
}
@@ -997,7 +997,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
// "Dispatch" on keyCode for these key codes to workaround issues with remote desktoping software
// where the scan codes appear to be incorrect (see https://github.com/microsoft/vscode/issues/24107)
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
if (immutableScanCode !== -1) {
if (immutableScanCode !== ScanCode.DependsOnKbLayout) {
code = immutableScanCode;
}
@@ -1019,7 +1019,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
// "Dispatch" on keyCode for all numpad keys in order for NumLock to work correctly
if (keyCode >= 0) {
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
if (immutableScanCode !== -1) {
if (immutableScanCode !== ScanCode.DependsOnKbLayout) {
code = immutableScanCode;
}
}

View File

@@ -180,7 +180,7 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
if (immutableKeyCode !== -1) {
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
this._scanCodeToKeyCode[scanCode] = immutableKeyCode;
this._keyCodeToLabel[immutableKeyCode] = KeyCodeUtils.toString(immutableKeyCode);
this._keyCodeExists[immutableKeyCode] = true;
@@ -201,7 +201,7 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
const rawMapping = rawMappings[strCode];
const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
if (immutableKeyCode !== -1) {
if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
const keyCode = NATIVE_KEY_CODE_TO_KEY_CODE[rawMapping.vkey] || KeyCode.Unknown;
if (keyCode === KeyCode.Unknown || immutableKeyCode === keyCode) {
continue;
@@ -337,7 +337,7 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
let cnt = 0;
result.push(`-----------------------------------------------------------------------------------------------------------------------------------------`);
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== -1) {
if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
if (immutableSamples.indexOf(scanCode) === -1) {
continue;
}

View File

@@ -13,9 +13,9 @@ import { MacLinuxFallbackKeyboardMapper } from 'vs/workbench/services/keybinding
import { MacLinuxKeyboardMapper } from 'vs/workbench/services/keybinding/common/macLinuxKeyboardMapper';
import { DispatchConfig } from 'vs/platform/keyboardLayout/common/dispatchConfig';
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
import { IKeyboardLayoutMainService } from 'vs/platform/keyboardLayout/common/keyboardLayoutMainService';
import { createChannelSender } from 'vs/base/parts/ipc/common/ipc';
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services';
import { INativeKeyboardLayoutService } from 'vs/platform/keyboardLayout/common/keyboardLayoutService';
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
export class KeyboardLayoutService extends Disposable implements IKeyboardLayoutService {
@@ -24,7 +24,7 @@ export class KeyboardLayoutService extends Disposable implements IKeyboardLayout
private readonly _onDidChangeKeyboardLayout = this._register(new Emitter<void>());
readonly onDidChangeKeyboardLayout = this._onDidChangeKeyboardLayout.event;
private readonly _keyboardLayoutMainService: IKeyboardLayoutMainService;
private readonly _keyboardLayoutService: INativeKeyboardLayoutService;
private _initPromise: Promise<void> | null;
private _keyboardMapping: IKeyboardMapping | null;
private _keyboardLayoutInfo: IKeyboardLayoutInfo | null;
@@ -34,13 +34,13 @@ export class KeyboardLayoutService extends Disposable implements IKeyboardLayout
@IMainProcessService mainProcessService: IMainProcessService
) {
super();
this._keyboardLayoutMainService = createChannelSender<IKeyboardLayoutMainService>(mainProcessService.getChannel('keyboardLayout'));
this._keyboardLayoutService = ProxyChannel.toService<INativeKeyboardLayoutService>(mainProcessService.getChannel('keyboardLayout'));
this._initPromise = null;
this._keyboardMapping = null;
this._keyboardLayoutInfo = null;
this._keyboardMapper = new MacLinuxFallbackKeyboardMapper(OS);
this._register(this._keyboardLayoutMainService.onDidChangeKeyboardLayout(async ({ keyboardLayoutInfo, keyboardMapping }) => {
this._register(this._keyboardLayoutService.onDidChangeKeyboardLayout(async ({ keyboardLayoutInfo, keyboardMapping }) => {
await this.initialize();
if (keyboardMappingEquals(this._keyboardMapping, keyboardMapping)) {
// the mappings are equal
@@ -62,7 +62,7 @@ export class KeyboardLayoutService extends Disposable implements IKeyboardLayout
}
private async _doInitialize(): Promise<void> {
const keyboardLayoutData = await this._keyboardLayoutMainService.getKeyboardLayoutData();
const keyboardLayoutData = await this._keyboardLayoutService.getKeyboardLayoutData();
const { keyboardLayoutInfo, keyboardMapping } = keyboardLayoutData;
this._keyboardMapping = keyboardMapping;
this._keyboardLayoutInfo = keyboardLayoutInfo;

View File

@@ -27,26 +27,26 @@ import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
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 { TestBackupFileService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestLifecycleService, TestPathService, TestTextFileService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestWorkingCopyBackupService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestLifecycleService, TestPathService, TestTextFileService } from 'vs/workbench/test/browser/workbenchTestServices';
import { FileService } from 'vs/platform/files/common/fileService';
import { Schemas } from 'vs/base/common/network';
import { URI } from 'vs/base/common/uri';
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { IWorkingCopyService, WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { ILabelService } from 'vs/platform/label/common/label';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { WorkingCopyFileService, IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
import { TestTextResourcePropertiesService, TestContextService, TestWorkingCopyService } from 'vs/workbench/test/common/workbenchTestServices';
import { TestTextResourcePropertiesService, TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
@@ -56,6 +56,7 @@ import { joinPath } from 'vs/base/common/resources';
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { VSBuffer } from 'vs/base/common/buffer';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
interface Modifiers {
metaKey?: boolean;
@@ -88,6 +89,7 @@ suite('KeybindingsEditing', () => {
configService.setUserConfiguration('files', { 'eol': '\n' });
instantiationService.stub(IEnvironmentService, environmentService);
instantiationService.stub(IWorkbenchEnvironmentService, environmentService);
instantiationService.stub(IPathService, new TestPathService());
instantiationService.stub(IConfigurationService, configService);
instantiationService.stub(IWorkspaceContextService, new TestContextService());
@@ -96,7 +98,7 @@ suite('KeybindingsEditing', () => {
instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService());
instantiationService.stub(IEditorService, new TestEditorService());
instantiationService.stub(IWorkingCopyService, new TestWorkingCopyService());
instantiationService.stub(IWorkingCopyService, disposables.add(new WorkingCopyService()));
instantiationService.stub(ITelemetryService, NullTelemetryService);
instantiationService.stub(IModeService, ModeServiceImpl);
instantiationService.stub(ILogService, new NullLogService());
@@ -109,11 +111,10 @@ suite('KeybindingsEditing', () => {
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
instantiationService.stub(IFileService, fileService);
instantiationService.stub(IUriIdentityService, new UriIdentityService(fileService));
instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));
instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));
instantiationService.stub(ITextFileService, disposables.add(instantiationService.createInstance(TestTextFileService)));
instantiationService.stub(ITextModelService, disposables.add(instantiationService.createInstance(TextModelResolverService)));
instantiationService.stub(IBackupFileService, new TestBackupFileService());
instantiationService.stub(IWorkingCopyBackupService, new TestWorkingCopyBackupService());
testObject = disposables.add(instantiationService.createInstance(KeybindingsEditingService));
@@ -127,7 +128,7 @@ suite('KeybindingsEditing', () => {
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined);
assert.fail('Should fail with parse errors');
} catch (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.');
assert.strictEqual(error.message, 'Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.');
}
});
@@ -137,7 +138,7 @@ suite('KeybindingsEditing', () => {
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined);
assert.fail('Should fail with parse errors');
} catch (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.');
assert.strictEqual(error.message, 'Unable to write to the keybindings configuration file. Please open it to correct errors/warnings in the file and try again.');
}
});
@@ -145,7 +146,7 @@ suite('KeybindingsEditing', () => {
instantiationService.stub(ITextFileService, 'isDirty', true);
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.'));
error => assert.strictEqual(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', async () => {
@@ -154,7 +155,7 @@ suite('KeybindingsEditing', () => {
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape } }), 'alt+c', undefined);
assert.fail('Should fail');
} catch (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.');
assert.strictEqual(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.');
}
});
@@ -162,59 +163,59 @@ suite('KeybindingsEditing', () => {
await fileService.writeFile(environmentService.keybindingsResource, VSBuffer.fromString(''));
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('edit a default keybinding to an empty array', async () => {
await writeToKeybindingsFile();
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined);
return assert.deepEqual(await getUserKeybindings(), expected);
return assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('edit a default keybinding in an existing array', async () => {
await writeToKeybindingsFile({ command: 'b', key: 'shift+c' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'shift+c', command: 'b' }, { key: 'alt+c', command: 'a' }, { key: 'escape', command: '-a' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined);
return assert.deepEqual(await getUserKeybindings(), expected);
return assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('add another keybinding', async () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }];
await testObject.addKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'a' }), 'alt+c', undefined);
return assert.deepEqual(await getUserKeybindings(), expected);
return assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('add a new default keybinding', async () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }];
await testObject.addKeybinding(aResolvedKeybindingItem({ command: 'a' }), 'alt+c', undefined);
return assert.deepEqual(await getUserKeybindings(), expected);
return assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('add a new default keybinding using edit', async () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'a' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a' }), 'alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('edit an user keybinding', async () => {
await writeToKeybindingsFile({ key: 'escape', command: 'b' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: 'b' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }), 'alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('edit an user keybinding with more than one element', async () => {
await 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' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ firstPart: { keyCode: KeyCode.Escape }, command: 'b', isDefault: false }), 'alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('remove a default keybinding', async () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }];
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('remove a default keybinding should not ad duplicate entries', async () => {
@@ -224,25 +225,25 @@ suite('KeybindingsEditing', () => {
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('remove a user keybinding', async () => {
await writeToKeybindingsFile({ key: 'alt+c', command: 'b' });
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'b', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } }, isDefault: false }));
assert.deepEqual(await getUserKeybindings(), []);
assert.deepStrictEqual(await getUserKeybindings(), []);
});
test('reset an edited keybinding', async () => {
await writeToKeybindingsFile({ key: 'alt+c', command: 'b' });
await testObject.resetKeybinding(aResolvedKeybindingItem({ command: 'b', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } }, isDefault: false }));
assert.deepEqual(await getUserKeybindings(), []);
assert.deepStrictEqual(await getUserKeybindings(), []);
});
test('reset a removed keybinding', async () => {
await writeToKeybindingsFile({ key: 'alt+c', command: '-b' });
await testObject.resetKeybinding(aResolvedKeybindingItem({ command: 'b', isDefault: false }));
assert.deepEqual(await getUserKeybindings(), []);
assert.deepStrictEqual(await getUserKeybindings(), []);
});
test('reset multiple removed keybindings', async () => {
@@ -250,42 +251,42 @@ suite('KeybindingsEditing', () => {
await writeToKeybindingsFile({ key: 'alt+shift+c', command: '-b' });
await writeToKeybindingsFile({ key: 'escape', command: '-b' });
await testObject.resetKeybinding(aResolvedKeybindingItem({ command: 'b', isDefault: false }));
assert.deepEqual(await getUserKeybindings(), []);
assert.deepStrictEqual(await getUserKeybindings(), []);
});
test('add a new keybinding to unassigned keybinding', async () => {
await writeToKeybindingsFile({ key: 'alt+c', command: '-a' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }, { key: 'shift+alt+c', command: 'a' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('add when expression', async () => {
await writeToKeybindingsFile({ key: 'alt+c', command: '-a' });
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }, { key: 'shift+alt+c', command: 'a', when: 'editorTextFocus' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', 'editorTextFocus');
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('update command and when expression', async () => {
await 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' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', 'editorTextFocus');
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('update when expression', async () => {
await 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' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false, when: 'editorTextFocus && !editorReadonly' }), 'shift+alt+c', 'editorTextFocus');
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
test('remove when expression', async () => {
await 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' }];
await testObject.editKeybinding(aResolvedKeybindingItem({ command: 'a', isDefault: false }), 'shift+alt+c', undefined);
assert.deepEqual(await getUserKeybindings(), expected);
assert.deepStrictEqual(await getUserKeybindings(), expected);
});
async function writeToKeybindingsFile(...keybindings: IUserFriendlyKeybinding[]): Promise<void> {

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import * as path from 'vs/base/common/path';
import { promises } from 'fs';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
import { Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
import { ScanCodeBinding } from 'vs/base/common/scanCode';
import { writeFile } from 'vs/base/node/pfs';
@@ -39,17 +39,17 @@ function toIResolvedKeybinding(kb: ResolvedKeybinding): IResolvedKeybinding {
export function assertResolveKeybinding(mapper: IKeyboardMapper, keybinding: Keybinding | null, expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveKeybinding(keybinding!).map(toIResolvedKeybinding);
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
}
export function assertResolveKeyboardEvent(mapper: IKeyboardMapper, keyboardEvent: IKeyboardEvent, expected: IResolvedKeybinding): void {
let actual = toIResolvedKeybinding(mapper.resolveKeyboardEvent(keyboardEvent));
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
}
export function assertResolveUserBinding(mapper: IKeyboardMapper, parts: (SimpleKeybinding | ScanCodeBinding)[], expected: IResolvedKeybinding[]): void {
let actual: IResolvedKeybinding[] = mapper.resolveUserBinding(parts).map(toIResolvedKeybinding);
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
}
export function readRawMapping<T>(file: string): Promise<T> {
@@ -74,6 +74,6 @@ export function assertMapping(writeFileIfDifferent: boolean, mapper: IKeyboardMa
const destPath = filePath.replace(/vscode[\/\\]out[\/\\]vs/, 'vscode/src/vs');
writeFile(destPath, actual);
}
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
});
}