Browse Source

Adds alwaysShow option to quickpick items

main
Eric Amodio 5 years ago
parent
commit
9db3e94a14
2 changed files with 28 additions and 7 deletions
  1. +1
    -1
      src/commands/quickCommand.helpers.ts
  2. +27
    -6
      src/quickpicks/gitQuickPicks.ts

+ 1
- 1
src/commands/quickCommand.helpers.ts View File

@ -152,7 +152,7 @@ export function getValidateGitReferenceFn(repo: Repository | Repository[]) {
if (!(await Container.git.validateReference(repo.path, value))) return false; if (!(await Container.git.validateReference(repo.path, value))) return false;
const commit = await Container.git.getCommit(repo.path, value); const commit = await Container.git.getCommit(repo.path, value);
quickpick.items = [CommitQuickPickItem.create(commit!, true, { compact: true, icon: true, match: value })];
quickpick.items = [CommitQuickPickItem.create(commit!, true, { alwaysShow: true, compact: true, icon: true })];
return true; return true;
}; };
} }

+ 27
- 6
src/quickpicks/gitQuickPicks.ts View File

@ -52,6 +52,7 @@ export namespace DirectiveQuickPickItem {
label: options.label || directive, label: options.label || directive,
description: options.description || '', description: options.description || '',
detail: options.detail, detail: options.detail,
alwaysShow: true,
picked: picked, picked: picked,
directive: directive directive: directive
}; };
@ -75,6 +76,7 @@ export namespace BranchQuickPickItem {
branch: GitBranch, branch: GitBranch,
picked?: boolean, picked?: boolean,
options: { options: {
alwaysShow?: boolean;
current?: boolean | 'checkmark'; current?: boolean | 'checkmark';
checked?: boolean; checked?: boolean;
ref?: boolean; ref?: boolean;
@ -152,6 +154,7 @@ export namespace BranchQuickPickItem {
branch.name branch.name
}${checked ? `${GlyphChars.Space.repeat(2)}$(check)${GlyphChars.Space}` : ''}`, }${checked ? `${GlyphChars.Space.repeat(2)}$(check)${GlyphChars.Space}` : ''}`,
description: description, description: description,
alwaysShow: options.alwaysShow,
picked: picked === undefined ? branch.current : picked, picked: picked === undefined ? branch.current : picked,
item: branch, item: branch,
current: branch.current, current: branch.current,
@ -169,7 +172,7 @@ export namespace CommitQuickPickItem {
export function create<T extends GitLogCommit = GitLogCommit>( export function create<T extends GitLogCommit = GitLogCommit>(
commit: T, commit: T,
picked?: boolean, picked?: boolean,
options: { compact?: boolean; icon?: boolean; match?: string } = {}
options: { alwaysShow?: boolean; compact?: boolean; icon?: boolean } = {}
) { ) {
if (GitStashCommit.is(commit)) { if (GitStashCommit.is(commit)) {
const number = commit.number === undefined ? '' : `${commit.number}: `; const number = commit.number === undefined ? '' : `${commit.number}: `;
@ -182,6 +185,7 @@ export namespace CommitQuickPickItem {
2, 2,
2 2
)}${commit.getFormattedDiffStatus({ compact: true })}`, )}${commit.getFormattedDiffStatus({ compact: true })}`,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: commit item: commit
}; };
@ -197,6 +201,7 @@ export namespace CommitQuickPickItem {
2, 2,
2 2
)}${commit.getFormattedDiffStatus({ compact: true })}`, )}${commit.getFormattedDiffStatus({ compact: true })}`,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: commit item: commit
}; };
@ -210,7 +215,7 @@ export namespace CommitQuickPickItem {
description: `${commit.author}, ${commit.formattedDate}${Strings.pad('$(git-commit)', 2, 2)}${ description: `${commit.author}, ${commit.formattedDate}${Strings.pad('$(git-commit)', 2, 2)}${
commit.shortSha commit.shortSha
}${Strings.pad(GlyphChars.Dot, 2, 2)}${commit.getFormattedDiffStatus({ compact: true })}`, }${Strings.pad(GlyphChars.Dot, 2, 2)}${commit.getFormattedDiffStatus({ compact: true })}`,
detail: options.match,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: commit item: commit
}; };
@ -219,7 +224,7 @@ export namespace CommitQuickPickItem {
const item: CommitQuickPickItem<T> = { const item: CommitQuickPickItem<T> = {
label: `${options.icon ? Strings.pad('$(git-commit)', 0, 2) : ''}${commit.getShortMessage()}`, label: `${options.icon ? Strings.pad('$(git-commit)', 0, 2) : ''}${commit.getShortMessage()}`,
description: options.match || '',
description: '',
detail: `${GlyphChars.Space.repeat(2)}${commit.author}, ${commit.formattedDate}${Strings.pad( detail: `${GlyphChars.Space.repeat(2)}${commit.author}, ${commit.formattedDate}${Strings.pad(
'$(git-commit)', '$(git-commit)',
2, 2,
@ -227,6 +232,7 @@ export namespace CommitQuickPickItem {
)}${commit.shortSha}${Strings.pad(GlyphChars.Dot, 2, 2)}${commit.getFormattedDiffStatus({ )}${commit.shortSha}${Strings.pad(GlyphChars.Dot, 2, 2)}${commit.getFormattedDiffStatus({
compact: true compact: true
})}`, })}`,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: commit item: commit
}; };
@ -237,10 +243,15 @@ export namespace CommitQuickPickItem {
export interface ContributorQuickPickItem extends QuickPickItemOfT<GitContributor> {} export interface ContributorQuickPickItem extends QuickPickItemOfT<GitContributor> {}
export namespace ContributorQuickPickItem { export namespace ContributorQuickPickItem {
export function create(contributor: GitContributor, picked?: boolean, options: {} = {}): ContributorQuickPickItem {
export function create(
contributor: GitContributor,
picked?: boolean,
options: { alwaysShow?: boolean } = {}
): ContributorQuickPickItem {
const item: ContributorQuickPickItem = { const item: ContributorQuickPickItem = {
label: contributor.name, label: contributor.name,
description: contributor.email, description: contributor.email,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: contributor item: contributor
}; };
@ -255,11 +266,16 @@ export interface RefQuickPickItem extends QuickPickItemOfT {
} }
export namespace RefQuickPickItem { export namespace RefQuickPickItem {
export function create(ref: string, picked?: boolean, options: { ref?: boolean } = {}): RefQuickPickItem {
export function create(
ref: string,
picked?: boolean,
options: { alwaysShow?: boolean; ref?: boolean } = {}
): RefQuickPickItem {
if (ref === '') { if (ref === '') {
return { return {
label: `${Strings.pad('$(file-directory)', 0, 2)}Working Tree`, label: `${Strings.pad('$(file-directory)', 0, 2)}Working Tree`,
description: '', description: '',
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: GitReference.create(ref, { name: 'Working Tree' }), item: GitReference.create(ref, { name: 'Working Tree' }),
current: false, current: false,
@ -272,6 +288,7 @@ export namespace RefQuickPickItem {
return { return {
label: 'HEAD', label: 'HEAD',
description: '', description: '',
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: GitReference.create(ref, { name: 'HEAD' }), item: GitReference.create(ref, { name: 'HEAD' }),
current: false, current: false,
@ -285,6 +302,7 @@ export namespace RefQuickPickItem {
const item: RefQuickPickItem = { const item: RefQuickPickItem = {
label: `Commit ${gitRef.name}`, label: `Commit ${gitRef.name}`,
description: options.ref ? `$(git-commit) ${ref}` : '', description: options.ref ? `$(git-commit) ${ref}` : '',
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: gitRef, item: gitRef,
current: false, current: false,
@ -304,7 +322,7 @@ export namespace RepositoryQuickPickItem {
export async function create( export async function create(
repository: Repository, repository: Repository,
picked?: boolean, picked?: boolean,
options: { branch?: boolean; fetched?: boolean; status?: boolean } = {}
options: { alwaysShow?: boolean; branch?: boolean; fetched?: boolean; status?: boolean } = {}
) { ) {
let repoStatus; let repoStatus;
if (options.branch || options.status) { if (options.branch || options.status) {
@ -348,6 +366,7 @@ export namespace RepositoryQuickPickItem {
const item: RepositoryQuickPickItem = { const item: RepositoryQuickPickItem = {
label: repository.formattedName, label: repository.formattedName,
description: description, description: description,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: repository, item: repository,
repoPath: repository.path repoPath: repository.path
@ -368,6 +387,7 @@ export namespace TagQuickPickItem {
tag: GitTag, tag: GitTag,
picked?: boolean, picked?: boolean,
options: { options: {
alwaysShow?: boolean;
message?: boolean; message?: boolean;
checked?: boolean; checked?: boolean;
ref?: boolean; ref?: boolean;
@ -399,6 +419,7 @@ export namespace TagQuickPickItem {
options.checked ? `${GlyphChars.Space.repeat(2)}$(check)${GlyphChars.Space}` : '' options.checked ? `${GlyphChars.Space.repeat(2)}$(check)${GlyphChars.Space}` : ''
}`, }`,
description: description, description: description,
alwaysShow: options.alwaysShow,
picked: picked, picked: picked,
item: tag, item: tag,
current: false, current: false,

Loading…
Cancel
Save