diff --git a/src/commands/git/cherry-pick.ts b/src/commands/git/cherry-pick.ts index 3268679..2dc1f08 100644 --- a/src/commands/git/cherry-pick.ts +++ b/src/commands/git/cherry-pick.ts @@ -66,8 +66,10 @@ export class CherryPickGitCommand extends QuickCommandBase { state.commits.sort((a, b) => a.date.getTime() - b.date.getTime()); runGitCommandInTerminal('cherry-pick', state.commits.map(c => c.sha).join(' '), state.repo.path, true); } + } - runGitCommandInTerminal('cherry-pick', state.source!.ref, state.repo.path, true); + isMatch(name: string) { + return super.isMatch(name) || name === 'cherry'; } protected async *steps(): StepAsyncGenerator { diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index 04ce2be..9665d54 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -63,6 +63,10 @@ export class SwitchGitCommand extends QuickCommandBase { )); } + isMatch(name: string) { + return super.isMatch(name) || name === 'checkout'; + } + protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; let oneRepo = false; diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index 6a0cb08..c988546 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -69,9 +69,13 @@ class PickCommandStep implements QuickPickStep { } } - find(commandName: string) { + find(commandName: string, fuzzy: boolean = false) { + if (fuzzy) { const cmd = commandName.toLowerCase(); - return this.items.find(c => c.label.replace(sanitizeLabel, '').toLowerCase() === cmd); + return this.items.find(c => c.isMatch(cmd)); + } + + return this.items.find(c => c.key === commandName); } } @@ -272,7 +276,7 @@ export class GitCommandsCommand extends Command { let items; if (commandsStep.command === undefined) { - const command = commandsStep.find(quickpick.value.trim()); + const command = commandsStep.find(quickpick.value.trim(), true); if (command === undefined) return; commandsStep.command = command; diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 56db4aa..e5305ce 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -108,6 +108,10 @@ export abstract class QuickCommandBase implements QuickPickItem { : !Container.config.gitCommands.skipConfirmations.includes(this.confirmationKey); } + isMatch(name: string) { + return this.label === name; + } + protected abstract steps(): StepAsyncGenerator; async previous(): Promise {