diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 82d7e39..f2f655e 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -1,9 +1,9 @@ import type { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; +import type { Keys } from '../constants'; import type { Container } from '../container'; import type { DirectiveQuickPickItem } from '../quickpicks/items/directive'; import { createDirectiveQuickPickItem, Directive, isDirective } from '../quickpicks/items/directive'; import { configuration } from '../system/configuration'; -import type { Keys } from '../system/keyboard'; export * from './quickCommand.buttons'; export * from './quickCommand.steps'; diff --git a/src/constants.ts b/src/constants.ts index bd34b99..5df4dbc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -306,7 +306,7 @@ export type WebviewViewIds = 'commitDetails' | 'graph' | 'home' | 'timeline'; export type ContextKeys = | `${typeof extensionPrefix}:action:${string}` - | `${typeof extensionPrefix}:key:${string}` + | `${typeof extensionPrefix}:key:${Keys}` | `${typeof extensionPrefix}:webview:${WebviewIds | CustomEditorIds}:${'active' | 'focus' | 'inputFocus'}` | `${typeof extensionPrefix}:webviewView:${WebviewViewIds}:${'active' | 'focus' | 'inputFocus'}` | `${typeof extensionPrefix}:activeFileStatus` @@ -443,6 +443,21 @@ export const enum GlyphChars { ZeroWidthSpace = '\u200b', } +export const keys = [ + 'left', + 'alt+left', + 'ctrl+left', + 'right', + 'alt+right', + 'ctrl+right', + 'alt+,', + 'alt+.', + 'alt+enter', + 'ctrl+enter', + 'escape', +] as const; +export type Keys = (typeof keys)[number]; + export const enum Schemes { DebugConsole = 'debug', File = 'file', diff --git a/src/quickpicks/commitPicker.ts b/src/quickpicks/commitPicker.ts index 358e5b3..e4beb37 100644 --- a/src/quickpicks/commitPicker.ts +++ b/src/quickpicks/commitPicker.ts @@ -1,12 +1,13 @@ import type { Disposable } from 'vscode'; import { window } from 'vscode'; +import type { Keys } from '../constants'; import { Container } from '../container'; import type { GitCommit, GitStashCommit } from '../git/models/commit'; import type { GitLog } from '../git/models/log'; import type { GitStash } from '../git/models/stash'; import { configuration } from '../system/configuration'; import { filter, map } from '../system/iterable'; -import type { KeyboardScope, Keys } from '../system/keyboard'; +import type { KeyboardScope } from '../system/keyboard'; import { isPromise } from '../system/promise'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import { CommandQuickPickItem } from './items/common'; diff --git a/src/quickpicks/items/commits.ts b/src/quickpicks/items/commits.ts index 8ed5ad1..7dc9fc9 100644 --- a/src/quickpicks/items/commits.ts +++ b/src/quickpicks/items/commits.ts @@ -2,6 +2,7 @@ import type { QuickPickItem } from 'vscode'; import { window } from 'vscode'; import type { OpenChangedFilesCommandArgs } from '../../commands/openChangedFiles'; import { RevealInSideBarQuickInputButton, ShowDetailsViewQuickInputButton } from '../../commands/quickCommand.buttons'; +import type { Keys } from '../../constants'; import { Commands, GlyphChars } from '../../constants'; import { Container } from '../../container'; import { browseAtRevision } from '../../git/actions'; @@ -11,7 +12,6 @@ import type { GitCommit } from '../../git/models/commit'; import type { GitFile, GitFileChange } from '../../git/models/file'; import { getGitFileFormattedDirectory, getGitFileStatusCodicon } from '../../git/models/file'; import type { GitStatusFile } from '../../git/models/status'; -import type { Keys } from '../../system/keyboard'; import { basename } from '../../system/path'; import { pad } from '../../system/string'; import { CommandQuickPickItem } from './common'; diff --git a/src/quickpicks/items/common.ts b/src/quickpicks/items/common.ts index fb3da5d..a83966b 100644 --- a/src/quickpicks/items/common.ts +++ b/src/quickpicks/items/common.ts @@ -1,7 +1,6 @@ import type { QuickPickItem } from 'vscode'; import { commands, QuickPickItemKind } from 'vscode'; -import type { Commands } from '../../constants'; -import type { Keys } from '../../system/keyboard'; +import type { Commands, Keys } from '../../constants'; declare module 'vscode' { interface QuickPickItem { diff --git a/src/quickpicks/referencePicker.ts b/src/quickpicks/referencePicker.ts index 2f63702..df4d358 100644 --- a/src/quickpicks/referencePicker.ts +++ b/src/quickpicks/referencePicker.ts @@ -5,6 +5,7 @@ import { getValidateGitReferenceFn, RevealInSideBarQuickInputButton, } from '../commands/quickCommand'; +import type { Keys } from '../constants'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { reveal as revealBranch } from '../git/actions/branch'; @@ -14,7 +15,7 @@ import type { BranchSortOptions, GitBranch } from '../git/models/branch'; import type { GitReference } from '../git/models/reference'; import { isBranchReference, isRevisionReference, isTagReference } from '../git/models/reference'; import type { GitTag, TagSortOptions } from '../git/models/tag'; -import type { KeyboardScope, Keys } from '../system/keyboard'; +import type { KeyboardScope } from '../system/keyboard'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import type { BranchQuickPickItem, RefQuickPickItem, TagQuickPickItem } from './items/gitCommands'; import { createRefQuickPickItem } from './items/gitCommands'; diff --git a/src/quickpicks/remoteProviderPicker.ts b/src/quickpicks/remoteProviderPicker.ts index 13dba1d..2e154e6 100644 --- a/src/quickpicks/remoteProviderPicker.ts +++ b/src/quickpicks/remoteProviderPicker.ts @@ -2,6 +2,7 @@ import type { Disposable, QuickInputButton } from 'vscode'; import { env, Uri, window } from 'vscode'; import type { OpenOnRemoteCommandArgs } from '../commands'; import { SetRemoteAsDefaultQuickInputButton } from '../commands/quickCommand.buttons'; +import type { Keys } from '../constants'; import { Commands, GlyphChars } from '../constants'; import { Container } from '../container'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/models/branch'; @@ -9,7 +10,6 @@ import { GitRemote } from '../git/models/remote'; import type { RemoteResource } from '../git/models/remoteResource'; import { getNameFromRemoteResource, RemoteResourceType } from '../git/models/remoteResource'; import type { RemoteProvider } from '../git/remotes/remoteProvider'; -import type { Keys } from '../system/keyboard'; import { getSettledValue } from '../system/promise'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import { CommandQuickPickItem } from './items/common'; diff --git a/src/system/keyboard.ts b/src/system/keyboard.ts index 4563c1c..f13b1a8 100644 --- a/src/system/keyboard.ts +++ b/src/system/keyboard.ts @@ -1,5 +1,6 @@ import { Disposable } from 'vscode'; -import { extensionPrefix } from '../constants'; +import type { Keys } from '../constants'; +import { extensionPrefix, keys } from '../constants'; import { setContext } from '../context'; import { registerCommand } from './command'; import { log } from './decorators/log'; @@ -13,21 +14,6 @@ export declare interface KeyCommand { const keyNoopCommand = Object.create(null) as KeyCommand; export { keyNoopCommand as KeyNoopCommand }; -export const keys = [ - 'left', - 'alt+left', - 'ctrl+left', - 'right', - 'alt+right', - 'ctrl+right', - 'alt+,', - 'alt+.', - 'alt+enter', - 'ctrl+enter', - 'escape', -] as const; -export type Keys = (typeof keys)[number]; - export type KeyMapping = { [K in Keys]?: KeyCommand | (() => Promise) }; type IndexableKeyMapping = KeyMapping & { [index: string]: KeyCommand | (() => Promise) | undefined;