Sfoglia il codice sorgente

Adds canConfirm flag for Git commands

main
Eric Amodio 5 anni fa
parent
commit
71f9a23cd4
3 ha cambiato i file con 12 aggiunte e 5 eliminazioni
  1. +5
    -1
      src/commands/git/stash.ts
  2. +1
    -2
      src/commands/gitCommands.ts
  3. +6
    -2
      src/commands/quickCommand.ts

+ 5
- 1
src/commands/git/stash.ts Vedi File

@ -108,12 +108,16 @@ export class StashGitCommand extends QuickCommandBase {
}; };
} }
get canConfirm(): boolean {
return this._subcommand !== undefined;
}
get canSkipConfirm(): boolean { get canSkipConfirm(): boolean {
return this._subcommand === 'drop' ? false : super.canSkipConfirm; return this._subcommand === 'drop' ? false : super.canSkipConfirm;
} }
get skipConfirmKey() { get skipConfirmKey() {
return this._subcommand === undefined ? undefined : `${this.key}-${this._subcommand}:${this.pickedVia}`;
return `${this.key}${this._subcommand === undefined ? '' : `-${this._subcommand}`}:${this.pickedVia}`;
} }
protected async *steps(): StepAsyncGenerator { protected async *steps(): StepAsyncGenerator {

+ 1
- 2
src/commands/gitCommands.ts Vedi File

@ -461,9 +461,8 @@ export class GitCommandsCommand extends Command {
} }
} }
if (!command.canConfirm) return buttons;
if (command.canSkipConfirm) { if (command.canSkipConfirm) {
if (command.skipConfirmKey === undefined) return buttons;
buttons.push( buttons.push(
command.confirm() ? this.GitQuickInputButtons.WillConfirm : this.GitQuickInputButtons.WillSkipConfirm command.confirm() ? this.GitQuickInputButtons.WillConfirm : this.GitQuickInputButtons.WillSkipConfirm
); );

+ 6
- 2
src/commands/quickCommand.ts Vedi File

@ -83,6 +83,10 @@ export abstract class QuickCommandBase implements QuickPickItem {
this.detail = options.detail; this.detail = options.detail;
} }
get canConfirm(): boolean {
return true;
}
get canSkipConfirm(): boolean { get canSkipConfirm(): boolean {
return true; return true;
} }
@ -106,12 +110,12 @@ export abstract class QuickCommandBase implements QuickPickItem {
this._pickedVia = value; this._pickedVia = value;
} }
get skipConfirmKey(): string | undefined {
get skipConfirmKey(): string {
return `${this.key}:${this.pickedVia}`; return `${this.key}:${this.pickedVia}`;
} }
confirm(override?: boolean) { confirm(override?: boolean) {
if (!this.canSkipConfirm || this.skipConfirmKey === undefined) return true;
if (!this.canConfirm || !this.canSkipConfirm) return true;
return override !== undefined return override !== undefined
? override ? override

Caricamento…
Annulla
Salva