2017-08-31 13:59:23 +00:00
|
|
|
/*---------------------------------------------------------------------------------------------
|
|
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
|
2019-08-14 13:50:14 +00:00
|
|
|
import { Code } from './code';
|
2017-08-31 13:59:23 +00:00
|
|
|
|
2018-09-24 08:33:34 +00:00
|
|
|
const SEARCH_INPUT = '.keybindings-header .settings-search-input input';
|
2017-10-10 12:18:55 +00:00
|
|
|
|
2017-08-31 13:59:23 +00:00
|
|
|
export class KeybindingsEditor {
|
|
|
|
|
2018-05-08 14:34:52 +00:00
|
|
|
constructor(private code: Code) { }
|
2017-08-31 13:59:23 +00:00
|
|
|
|
2020-12-02 16:48:16 +00:00
|
|
|
async updateKeybinding(command: string, commandName: string | undefined, keybinding: string, keybindingTitle: string): Promise<any> {
|
2018-05-08 14:34:52 +00:00
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
await this.code.dispatchKeybinding('cmd+k cmd+s');
|
|
|
|
} else {
|
|
|
|
await this.code.dispatchKeybinding('ctrl+k ctrl+s');
|
|
|
|
}
|
|
|
|
|
2018-04-11 14:20:09 +00:00
|
|
|
await this.code.waitForActiveElement(SEARCH_INPUT);
|
2020-12-02 16:48:16 +00:00
|
|
|
await this.code.waitForSetValue(SEARCH_INPUT, `@command:${command}`);
|
2017-08-31 13:59:23 +00:00
|
|
|
|
2020-12-02 16:48:16 +00:00
|
|
|
const commandTitle = commandName ? `${commandName} (${command})` : command;
|
2024-02-28 15:37:07 +00:00
|
|
|
await this.code.waitAndClick(`.keybindings-table-container .monaco-list-row .command[aria-label="${commandTitle}"]`);
|
|
|
|
await this.code.waitForElement(`.keybindings-table-container .monaco-list-row.focused.selected .command[aria-label="${commandTitle}"]`);
|
2020-12-02 16:48:16 +00:00
|
|
|
await this.code.dispatchKeybinding('enter');
|
2017-08-31 13:59:23 +00:00
|
|
|
|
2018-06-04 14:27:18 +00:00
|
|
|
await this.code.waitForActiveElement('.defineKeybindingWidget .monaco-inputbox input');
|
2018-04-11 14:20:09 +00:00
|
|
|
await this.code.dispatchKeybinding(keybinding);
|
|
|
|
await this.code.dispatchKeybinding('enter');
|
2024-02-28 15:37:07 +00:00
|
|
|
await this.code.waitForElement(`.keybindings-table-container .keybinding-label div[aria-label="${keybindingTitle}"]`);
|
2017-08-31 13:59:23 +00:00
|
|
|
}
|
2019-08-14 13:50:14 +00:00
|
|
|
}
|