Ver código fonte

Adds isMatch to commands for fuzzy matching

main
Eric Amodio 5 anos atrás
pai
commit
dbaac5f26c
4 arquivos alterados com 18 adições e 4 exclusões
  1. +3
    -1
      src/commands/git/cherry-pick.ts
  2. +4
    -0
      src/commands/git/switch.ts
  3. +7
    -3
      src/commands/gitCommands.ts
  4. +4
    -0
      src/commands/quickCommand.ts

+ 3
- 1
src/commands/git/cherry-pick.ts Ver arquivo

@ -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 {

+ 4
- 0
src/commands/git/switch.ts Ver arquivo

@ -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<State> = this._initialState === undefined ? { counter: 0 } : this._initialState;
let oneRepo = false;

+ 7
- 3
src/commands/gitCommands.ts Ver arquivo

@ -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;

+ 4
- 0
src/commands/quickCommand.ts Ver arquivo

@ -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<QuickPickStep | QuickInputStep | undefined> {

Carregando…
Cancelar
Salvar