From a37a80d7047bd47bb6e0887f65231f3623adb9b3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 11 Mar 2017 00:40:39 -0500 Subject: [PATCH] Exposes Keys Adds keyboard logging --- src/commands.ts | 2 +- src/commands/keyboard.ts | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 7d7b104..da6dd55 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -2,7 +2,7 @@ import { commands } from 'vscode'; import { BuiltInCommands } from './constants'; -export { Keyboard } from './commands/keyboard'; +export { Keyboard, Keys } from './commands/keyboard'; export { ActiveEditorCommand, Command, Commands, EditorCommand, openEditor } from './commands/commands'; export { CloseUnchangedFilesCommand } from './commands/closeUnchangedFiles'; diff --git a/src/commands/keyboard.ts b/src/commands/keyboard.ts index 67c1985..f30f02b 100644 --- a/src/commands/keyboard.ts +++ b/src/commands/keyboard.ts @@ -2,10 +2,10 @@ import { commands, Disposable, ExtensionContext, QuickPickItem } from 'vscode'; import { CommandContext, setCommandContext } from '../commands'; import { CommandQuickPickItem, OpenFileCommandQuickPickItem } from '../quickPicks/quickPicks'; -//import { Logger } from '../logger'; +import { Logger } from '../logger'; -declare type Keys = 'left' | 'right'; -const keys: Keys[] = [ +export declare type Keys = 'left' | 'right'; +export const keys: Keys[] = [ 'left', 'right' ]; @@ -40,19 +40,22 @@ export class Keyboard extends Disposable { this._disposable && this._disposable.dispose(); } - execute(key: Keys): any { + async execute(key: Keys): Promise<{}> { const command = this.context.globalState.get(`gitlens:key:${key}`) as CommandQuickPickItem; if (!command || !(command instanceof CommandQuickPickItem)) return undefined; + Logger.log('Keyboard.execute', key); + if (command instanceof OpenFileCommandQuickPickItem) { // Have to open this pinned right now, because vscode doesn't have a way to open a unpinned, but unfocused editor - return command.execute(true); + return await command.execute(true); } - return command.execute(); + return await command.execute(); } async enterScope(...keyCommands: [Keys, QuickPickItem][]) { + Logger.log('Keyboard.enterScope', scopeCount); await setCommandContext(CommandContext.Key, ++scopeCount); if (keyCommands && Array.isArray(keyCommands) && keyCommands.length) { for (const [key, command] of keyCommands) { @@ -62,6 +65,7 @@ export class Keyboard extends Disposable { } async exitScope(clear: boolean = true) { + Logger.log('Keyboard.exitScope', scopeCount); await setCommandContext(CommandContext.Key, --scopeCount); if (clear && !scopeCount) { for (const key of keys) { @@ -71,10 +75,12 @@ export class Keyboard extends Disposable { } async clearKeyCommand(key: Keys) { + Logger.log('Keyboard.clearKeyCommand', key); await this.context.globalState.update(`gitlens:key:${key}`, undefined); } async setKeyCommand(key: Keys, command: QuickPickItem) { + Logger.log('Keyboard.setKeyCommand', key); await this.context.globalState.update(`gitlens:key:${key}`, command); } } \ No newline at end of file