Browse Source

Removes reveal/search from commit quickpick items

In favor of the same options as buttons on the commit item itself
main
Eric Amodio 2 years ago
parent
commit
8c01c228a7
2 changed files with 2 additions and 84 deletions
  1. +1
    -22
      src/commands/quickCommand.steps.ts
  2. +1
    -62
      src/quickpicks/quickPicksItems.ts

+ 1
- 22
src/commands/quickCommand.steps.ts View File

@ -60,8 +60,6 @@ import {
ReferencesQuickPickItem,
RefQuickPickItem,
RepositoryQuickPickItem,
RevealInSideBarQuickPickItem,
SearchForCommitQuickPickItem,
TagQuickPickItem,
} from '../quickpicks';
import { Arrays, Iterables, Strings } from '../system';
@ -1468,12 +1466,7 @@ async function getShowCommitOrStashStepItems<
const items: (CommandQuickPickItem | QuickPickSeparator)[] = [new CommitFilesQuickPickItem(state.reference)];
if (GitCommit.isStash(state.reference)) {
items.push(
QuickPickSeparator.create(),
new RevealInSideBarQuickPickItem(state.reference),
QuickPickSeparator.create(),
new CommitCopyMessageQuickPickItem(state.reference),
);
items.push(QuickPickSeparator.create(), new CommitCopyMessageQuickPickItem(state.reference));
items.push(
QuickPickSeparator.create('Actions'),
@ -1496,12 +1489,6 @@ async function getShowCommitOrStashStepItems<
}),
);
} else {
items.push(
QuickPickSeparator.create(),
new RevealInSideBarQuickPickItem(state.reference),
new SearchForCommitQuickPickItem(state.reference),
);
const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true });
if (remotes?.length) {
items.push(
@ -1836,18 +1823,10 @@ async function getShowCommitOrStashFileStepItems<
if (GitCommit.isStash(state.reference)) {
items.push(
QuickPickSeparator.create(),
new RevealInSideBarQuickPickItem(state.reference),
QuickPickSeparator.create(),
new CommitCopyMessageQuickPickItem(state.reference),
QuickPickSeparator.create('Actions'),
);
} else {
items.push(
QuickPickSeparator.create(),
new RevealInSideBarQuickPickItem(state.reference),
new SearchForCommitQuickPickItem(state.reference),
);
const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true });
if (remotes?.length) {
items.push(

+ 1
- 62
src/quickpicks/quickPicksItems.ts View File

@ -1,8 +1,5 @@
import { commands, QuickPickItem, QuickPickItemKind } from 'vscode';
import { Commands, GitActions } from '../commands';
import { Container } from '../container';
import { GitCommit, GitReference, GitRevisionReference } from '../git/models';
import { SearchPattern } from '../git/search';
import { Commands } from '../commands';
import { Keys } from '../keyboard';
declare module 'vscode' {
@ -196,61 +193,3 @@ function hasFlags(flags: T[], has?: T | T[]): boolean {
return has.length === 0 ? flags.length === 0 : has.every(f => flags.includes(f));
}
export class RevealInSideBarQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly reference: GitRevisionReference,
item: QuickPickItem = {
label: `$(eye) Reveal ${GitReference.isStash(reference) ? 'Stash' : 'Commit'} in Side Bar`,
description: GitReference.isStash(reference) ? '' : 'can take a while',
},
) {
super(item, undefined, undefined);
}
override async execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
if (GitCommit.isStash(this.reference)) {
void (await GitActions.Stash.reveal(this.reference, {
select: true,
focus: !(options?.preserveFocus ?? false),
expand: true,
}));
} else {
void (await GitActions.Commit.reveal(this.reference, {
select: true,
focus: !(options?.preserveFocus ?? false),
expand: true,
}));
}
}
}
export class SearchForCommitQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly reference: GitRevisionReference,
item: QuickPickItem = {
label: '$(search) Search for Commit in Side Bar',
},
) {
super(item, undefined, undefined);
}
override async execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
void (await Container.instance.searchAndCompareView.search(
this.reference.repoPath,
{
pattern: SearchPattern.fromCommit(this.reference),
},
{
label: {
label: `for ${GitReference.toString(this.reference, { icon: false })}`,
},
reveal: {
select: true,
focus: !(options?.preserveFocus ?? false),
expand: true,
},
},
));
}
}

Loading…
Cancel
Save