소스 검색

Adds keep open button to Git commands

main
Eric Amodio 5 년 전
부모
커밋
4c1cefd997
3개의 변경된 파일83개의 추가작업 그리고 25개의 파일을 삭제
  1. +4
    -0
      images/dark/icon-pin-small-selected.svg
  2. +4
    -0
      images/light/icon-pin-small-selected.svg
  3. +75
    -25
      src/commands/gitCommands.ts

+ 4
- 0
images/dark/icon-pin-small-selected.svg 파일 보기

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#fff" fill-opacity=".1" stroke="#C5C5C5" stroke-width=".5" d="M.25.25h15.5v15.5H.25z"/>
<path fill="#C5C5C5" fill-rule="evenodd" d="M5.47 1.518c-.2.029-.323.283-.252.516.025.082.037.097.248.307l.434.33.402.229s.343.092.234.309c-.022.048-.702 3.532-.702 3.532l-.055.229c-.03.158-.335.453-.335.453l-1.387 1.39s-.349.36-.527.553c-.067.136-.014.356.081.45.125.125-.037.116 1.99.116 2.078 0 1.865.24 1.865.24s.161 4.102.234 4.328c.073.226.525.222.6 0 .065-.222.236-4.328.236-4.328s-.211-.234 1.863-.24c2.03.002 1.862.013 1.996-.117.089-.097.141-.33.075-.455l-.521-.546s-.937-.929-1.4-1.391c-.289-.29-.296-.283-.329-.455a2.352 2.352 0 0 0-.056-.227S9.5 3.324 9.463 3.208c-.1-.216.234-.308.234-.308l.402-.226s.133-.023.434-.333c.212-.212.23-.242.253-.307.07-.235.06-.485-.258-.519-.08-.011-1.3-.116-2.521-.115-1.229.001-2.46.108-2.536.118zM8.347 2.56l.937 4.636s.047.25.111.397c.181.416.725.796.725.796s.669.57.502.625c-.156.068-5.08.067-5.241 0-.167-.057.502-.625.502-.625s.54-.38.724-.796c.066-.147.115-.397.115-.397l.934-4.637s.208-.102.35-.1c.139 0 .341.101.341.101z" clip-rule="evenodd"/>
</svg>

+ 4
- 0
images/light/icon-pin-small-selected.svg 파일 보기

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#000" fill-opacity=".1" stroke="#424242" stroke-width=".5" d="M.25.25h15.5v15.5H.25z"/>
<path fill="#424242" fill-rule="evenodd" d="M5.47 1.518c-.2.029-.323.283-.252.516.025.082.037.097.248.307l.434.33.402.229s.343.092.234.309c-.022.048-.702 3.532-.702 3.532l-.055.229c-.03.158-.335.453-.335.453l-1.387 1.39s-.349.36-.527.553c-.067.136-.014.356.081.45.125.125-.037.116 1.99.116 2.078 0 1.865.24 1.865.24s.161 4.102.234 4.328c.073.226.525.222.6 0 .065-.222.236-4.328.236-4.328s-.211-.234 1.863-.24c2.03.002 1.862.013 1.996-.117.089-.097.141-.33.075-.455l-.521-.546s-.937-.929-1.4-1.391c-.289-.29-.296-.283-.329-.455a2.352 2.352 0 0 0-.056-.227S9.5 3.324 9.463 3.208c-.1-.216.234-.308.234-.308l.402-.226s.133-.023.434-.333c.212-.212.23-.242.253-.307.07-.235.06-.485-.258-.519-.08-.011-1.3-.116-2.521-.115-1.229.001-2.46.108-2.536.118zM8.347 2.56l.937 4.636s.047.25.111.397c.181.416.725.796.725.796s.669.57.502.625c-.156.068-5.08.067-5.241 0-.167-.057.502-.625.502-.625s.54-.38.724-.796c.066-.147.115-.397.115-.397l.934-4.637s.208-.102.35-.1c.139 0 .341.101.341.101z" clip-rule="evenodd"/>
</svg>

+ 75
- 25
src/commands/gitCommands.ts 파일 보기

@ -43,6 +43,22 @@ export type GitCommandsCommandArgs =
@command()
export class GitCommandsCommand extends Command {
private readonly GitQuickInputButtons = class {
static readonly CloseOnFocusOut: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-pin-small.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-pin-small.svg') as any
},
tooltip: 'Keep Open'
};
static readonly KeepOpen: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-pin-small-selected.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-pin-small-selected.svg') as any
},
tooltip: 'Keep Open'
};
static readonly WillConfirm: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-check.svg') as any,
@ -139,6 +155,15 @@ export class GitCommandsCommand extends Command {
return;
}
if (
e === this.GitQuickInputButtons.CloseOnFocusOut ||
e === this.GitQuickInputButtons.KeepOpen
) {
await this.toggleKeepOpen(input, commandsStep.command);
return;
}
if (step.onDidClickButton !== undefined) {
step.onDidClickButton(input, e);
input.buttons = this.getButtons(step, commandsStep.command);
@ -201,6 +226,8 @@ export class GitCommandsCommand extends Command {
if (e === this.GitQuickInputButtons.WillConfirmForced) return;
if (
e === this.GitQuickInputButtons.CloseOnFocusOut ||
e === this.GitQuickInputButtons.KeepOpen ||
e === this.GitQuickInputButtons.WillConfirm ||
e === this.GitQuickInputButtons.WillSkipConfirm
) {
@ -212,7 +239,19 @@ export class GitCommandsCommand extends Command {
command = active;
}
await this.toggleConfirmation(quickpick, command);
if (
e === this.GitQuickInputButtons.WillConfirm ||
e === this.GitQuickInputButtons.WillSkipConfirm
) {
await this.toggleConfirmation(quickpick, command);
}
if (
e === this.GitQuickInputButtons.CloseOnFocusOut ||
e === this.GitQuickInputButtons.KeepOpen
) {
await this.toggleKeepOpen(quickpick, command);
}
return;
}
@ -289,20 +328,7 @@ export class GitCommandsCommand extends Command {
const command = quickpick.activeItems[0];
if (!QuickCommandBase.is(command)) return;
const buttons: QuickInputButton[] = [];
if (command.canSkipConfirm) {
if (command.skipConfirmKey !== undefined) {
buttons.push(
command.confirm()
? this.GitQuickInputButtons.WillConfirm
: this.GitQuickInputButtons.WillSkipConfirm
);
}
} else {
buttons.push(this.GitQuickInputButtons.WillConfirmForced);
}
quickpick.buttons = buttons;
quickpick.buttons = this.getButtons(undefined, command);
}),
quickpick.onDidAccept(async () => {
let items = quickpick.selectedItems;
@ -412,12 +438,18 @@ export class GitCommandsCommand extends Command {
}
private getButtons(step: QuickInputStep | QuickPickStep | undefined, command?: QuickCommandBase) {
if (command === undefined) return [];
const buttons: QuickInputButton[] = [];
if (step !== undefined) {
if (step.buttons !== undefined) return step.buttons;
if (step.buttons !== undefined) {
buttons.push(
...step.buttons,
configuration.get('gitCommands', 'closeOnFocusOut')
? this.GitQuickInputButtons.CloseOnFocusOut
: this.GitQuickInputButtons.KeepOpen
);
return buttons;
}
buttons.push(QuickInputButtons.Back);
@ -426,15 +458,24 @@ export class GitCommandsCommand extends Command {
}
}
if (!command.canConfirm) return buttons;
if (command.canSkipConfirm) {
buttons.push(
command.confirm() ? this.GitQuickInputButtons.WillConfirm : this.GitQuickInputButtons.WillSkipConfirm
);
} else {
buttons.push(this.GitQuickInputButtons.WillConfirmForced);
if (command !== undefined && command.canConfirm) {
if (command.canSkipConfirm) {
buttons.push(
command.confirm()
? this.GitQuickInputButtons.WillConfirm
: this.GitQuickInputButtons.WillSkipConfirm
);
} else {
buttons.push(this.GitQuickInputButtons.WillConfirmForced);
}
}
buttons.push(
configuration.get('gitCommands', 'closeOnFocusOut')
? this.GitQuickInputButtons.CloseOnFocusOut
: this.GitQuickInputButtons.KeepOpen
);
return buttons;
}
@ -472,6 +513,15 @@ export class GitCommandsCommand extends Command {
input.buttons = this.getButtons(command.value, command);
}
private async toggleKeepOpen(input: InputBox | QuickPick<QuickPickItem>, command: QuickCommandBase | undefined) {
const closeOnFocusOut = !configuration.get('gitCommands', 'closeOnFocusOut');
input.ignoreFocusOut = !closeOnFocusOut;
void (await configuration.updateEffective('gitCommands', 'closeOnFocusOut', closeOnFocusOut));
input.buttons = this.getButtons(command && command.value, command);
}
}
class PickCommandStep implements QuickPickStep {

불러오는 중...
취소
저장