Browse Source

Changes quick pick "eye" to open commit details

Changes "search" to reveal in the side bar
Adds "Show Details" to commit/commit file quick pick
main
Eric Amodio 2 years ago
parent
commit
16cdd1091b
7 changed files with 132 additions and 192 deletions
  1. +4
    -1
      src/commands/git/log.ts
  2. +4
    -1
      src/commands/git/search.ts
  3. +14
    -4
      src/commands/git/stash.ts
  4. +4
    -4
      src/commands/quickCommand.buttons.ts
  5. +98
    -174
      src/commands/quickCommand.steps.ts
  6. +4
    -7
      src/quickpicks/items/commits.ts
  7. +4
    -1
      src/quickpicks/referencePicker.ts

+ 4
- 1
src/commands/git/log.ts View File

@ -191,7 +191,10 @@ export class LogGitCommand extends QuickCommand {
let result: StepResult<ReturnType<typeof getSteps>>;
if (state.openPickInView) {
void GitActions.Commit.showDetailsView(state.reference as GitCommit);
void GitActions.Commit.showDetailsView(state.reference as GitCommit, {
pin: false,
preserveFocus: false,
});
result = StepResult.Break;
} else {
result = yield* getSteps(

+ 4
- 1
src/commands/git/search.ts View File

@ -245,7 +245,10 @@ export class SearchGitCommand extends QuickCommand {
let result: StepResult<ReturnType<typeof getSteps>>;
if (state.openPickInView) {
void GitActions.Commit.showDetailsView(context.commit);
void GitActions.Commit.showDetailsView(context.commit, {
pin: false,
preserveFocus: false,
});
result = StepResult.Break;
} else {
result = yield* getSteps(

+ 14
- 4
src/commands/git/stash.ts View File

@ -364,9 +364,14 @@ export class StashGitCommand extends QuickCommand {
undefined,
{
placeholder: `Confirm ${context.title}`,
additionalButtons: [QuickCommandButtons.RevealInSideBar],
additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickButton: (quickpick, button) => {
if (button === QuickCommandButtons.RevealInSideBar) {
if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(state.reference, {
pin: false,
preserveFocus: true,
});
} else if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Stash.reveal(state.reference, {
select: true,
expand: true,
@ -423,9 +428,14 @@ export class StashGitCommand extends QuickCommand {
undefined,
{
placeholder: `Confirm ${context.title}`,
additionalButtons: [QuickCommandButtons.RevealInSideBar],
additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickButton: (quickpick, button) => {
if (button === QuickCommandButtons.RevealInSideBar) {
if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(state.reference, {
pin: false,
preserveFocus: true,
});
} else if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Stash.reveal(state.reference, {
select: true,
expand: true,

+ 4
- 4
src/commands/quickCommand.buttons.ts View File

@ -113,14 +113,14 @@ export namespace QuickCommandButtons {
tooltip: 'Open in New Window',
};
export const RevealInSideBar: QuickInputButton = {
export const ShowDetailsView: QuickInputButton = {
iconPath: new ThemeIcon('eye'),
tooltip: 'Reveal in Side Bar',
tooltip: 'Show Details',
};
export const SearchInSideBar: QuickInputButton = {
export const RevealInSideBar: QuickInputButton = {
iconPath: new ThemeIcon('search'),
tooltip: 'Search in Side Bar',
tooltip: 'Reveal in Side Bar',
};
export const ShowResultsInSideBar: QuickInputButton = {

+ 98
- 174
src/commands/quickCommand.steps.ts View File

@ -20,7 +20,6 @@ import type { GitTag, TagSortOptions } from '../git/models/tag';
import { sortTags } from '../git/models/tag';
import type { GitWorktree } from '../git/models/worktree';
import { RemoteResourceType } from '../git/remotes/provider';
import { SearchPattern } from '../git/search';
import {
CommitApplyFileChangesCommandQuickPickItem,
CommitBrowseRepositoryFromHereCommandQuickPickItem,
@ -706,7 +705,7 @@ export async function* pickBranchOrTagStep<
} else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) {
void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true });
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
}
}
return false;
@ -744,7 +743,7 @@ export async function* pickBranchOrTagStep<
} else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) {
void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true });
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
}
},
onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }),
@ -816,7 +815,7 @@ export async function* pickBranchOrTagStepMultiRepo<
} else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) {
void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true });
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
}
}
},
@ -859,7 +858,7 @@ export async function* pickBranchOrTagStepMultiRepo<
} else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) {
void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true });
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
}
},
onValidateValue: getValidateGitReferenceFn(state.repos),
@ -908,7 +907,7 @@ export async function* pickCommitStep<
picked != null &&
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
{
buttons: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
buttons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
compact: true,
icon: true,
},
@ -944,6 +943,10 @@ export async function* pickCommitStep<
if (CommandQuickPickItem.is(item)) return;
switch (button) {
case QuickCommandButtons.ShowDetailsView:
void GitActions.Commit.showDetailsView(item.item, { pin: false, preserveFocus: true });
break;
case QuickCommandButtons.RevealInSideBar:
void GitActions.Commit.reveal(item.item, {
select: true,
@ -951,23 +954,6 @@ export async function* pickCommitStep<
expand: true,
});
break;
case QuickCommandButtons.SearchInSideBar:
void Container.instance.searchAndCompareView.search(
state.repo.path,
{ pattern: SearchPattern.fromCommit(item.item.ref) },
{
label: {
label: `for ${GitReference.toString(item.item, { icon: false })}`,
},
reveal: {
select: true,
focus: false,
expand: true,
},
},
);
break;
}
},
onDidClickButton: (quickpick, button) => {
@ -990,29 +976,17 @@ export async function* pickCommitStep<
);
if (key === 'ctrl+right') {
void GitActions.Commit.showDetailsView(items[0].item, { pin: false, preserveFocus: true });
} else {
await GitActions.Commit.reveal(items[0].item, {
select: true,
focus: false,
expand: true,
});
} else {
const commit = items[0].item;
await Container.instance.searchAndCompareView.search(
commit.repoPath,
{ pattern: SearchPattern.fromCommit(commit) },
{
label: { label: `for ${GitReference.toString(commit, { icon: false })}` },
reveal: {
select: true,
focus: false,
expand: true,
},
},
);
}
},
onValidateValue: getValidateGitReferenceFn(state.repo, {
buttons: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
buttons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
}),
});
const selection: StepSelection<typeof step> = yield step;
@ -1058,7 +1032,7 @@ export function* pickCommitsStep<
picked != null &&
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
{
buttons: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
buttons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
compact: true,
icon: true,
},
@ -1088,6 +1062,10 @@ export function* pickCommitsStep<
additionalButtons: [...(log?.hasMore ? [QuickCommandButtons.LoadMore] : [])],
onDidClickItemButton: (quickpick, button, { item }) => {
switch (button) {
case QuickCommandButtons.ShowDetailsView:
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
break;
case QuickCommandButtons.RevealInSideBar:
void GitActions.Commit.reveal(item, {
select: true,
@ -1095,23 +1073,6 @@ export function* pickCommitsStep<
expand: true,
});
break;
case QuickCommandButtons.SearchInSideBar:
void Container.instance.searchAndCompareView.search(
state.repo.path,
{ pattern: SearchPattern.fromCommit(item.ref) },
{
label: {
label: `for ${GitReference.toString(item, { icon: false })}`,
},
reveal: {
select: true,
focus: false,
expand: true,
},
},
);
break;
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
@ -1119,25 +1080,16 @@ export function* pickCommitsStep<
if (quickpick.activeItems.length === 0) return;
if (key === 'ctrl+right') {
void GitActions.Commit.showDetailsView(quickpick.activeItems[0].item, {
pin: false,
preserveFocus: true,
});
} else {
await GitActions.Commit.reveal(quickpick.activeItems[0].item, {
select: true,
focus: false,
expand: true,
});
} else {
const commit = quickpick.activeItems[0].item;
await Container.instance.searchAndCompareView.search(
commit.repoPath,
{ pattern: SearchPattern.fromCommit(commit) },
{
label: { label: `for ${GitReference.toString(commit, { icon: false })}` },
reveal: {
select: true,
focus: false,
expand: true,
},
},
);
}
},
});
@ -1342,7 +1294,7 @@ export function* pickStashStep<
picked != null &&
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
{
buttons: [QuickCommandButtons.RevealInSideBar],
buttons: [QuickCommandButtons.ShowDetailsView],
compact: true,
icon: true,
},
@ -1350,23 +1302,15 @@ export function* pickStashStep<
),
],
onDidClickItemButton: (_quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Stash.reveal(item, {
select: true,
focus: false,
expand: true,
});
if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(item, { pin: false, preserveFocus: true });
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return;
await GitActions.Stash.reveal(quickpick.activeItems[0].item, {
select: true,
focus: false,
expand: true,
});
await GitActions.Stash.showDetailsView(quickpick.activeItems[0].item, { pin: false, preserveFocus: true });
},
});
const selection: StepSelection<typeof step> = yield step;
@ -1571,41 +1515,34 @@ export async function* showCommitOrStashStep<
placeholder: GitReference.toString(state.reference, { capitalize: true, icon: false }),
ignoreFocusOut: true,
items: await getShowCommitOrStashStepItems(state),
// additionalButtons: GitReference.isStash(state.reference)
// ? [QuickCommandButtons.RevealInSideBar]
// : [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
// additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickItemButton: (quickpick, button, _item) => {
if (button === QuickCommandButtons.SearchInSideBar) {
void Container.instance.searchAndCompareView.search(
state.repo.path,
{ pattern: SearchPattern.fromCommit(state.reference.ref) },
{
label: { label: `for ${GitReference.toString(state.reference, { icon: false })}` },
reveal: {
switch (button) {
case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else {
void GitActions.Commit.showDetailsView(state.reference, {
pin: false,
preserveFocus: true,
});
}
break;
case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
},
},
);
return;
}
if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
break;
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
@ -1622,7 +1559,9 @@ export async function* showCommitOrStashStep<
async function getShowCommitOrStashStepItems<
State extends PartialStepState & { repo: Repository; reference: GitCommit | GitStashCommit },
>(state: State): Promise<CommandQuickPickItem[]> {
const items: (CommandQuickPickItem | QuickPickSeparator)[] = [];
const items: (CommandQuickPickItem | QuickPickSeparator)[] = [
new CommitOpenDetailsCommandQuickPickItem(state.reference),
];
let unpublished: boolean | undefined;
@ -1780,7 +1719,6 @@ async function getShowCommitOrStashStepItems<
new CommitOpenAllChangesWithWorkingCommandQuickPickItem(state.reference),
new CommitOpenAllChangesWithDiffToolCommandQuickPickItem(state.reference),
QuickPickSeparator.create(),
new CommitOpenDetailsCommandQuickPickItem(state.reference),
new CommitOpenFilesCommandQuickPickItem(state.reference),
new CommitOpenRevisionsCommandQuickPickItem(state.reference),
);
@ -1860,39 +1798,31 @@ export function* showCommitOrStashFilesStep<
) ?? []),
] as (CommitFilesQuickPickItem | CommitFileQuickPickItem)[],
matchOnDescription: true,
// additionalButtons: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
// additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickItemButton: (quickpick, button, _item) => {
if (button === QuickCommandButtons.SearchInSideBar) {
void Container.instance.searchAndCompareView.search(
state.repo.path,
{ pattern: SearchPattern.fromCommit(state.reference.ref) },
{
label: { label: `for ${GitReference.toString(state.reference, { icon: false })}` },
reveal: {
switch (button) {
case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else {
void GitActions.Commit.showDetailsView(state.reference, { pin: false, preserveFocus: true });
}
break;
case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
},
},
);
return;
}
if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
break;
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
@ -1932,39 +1862,31 @@ export async function* showCommitOrStashFileStep<
ignoreFocusOut: true,
items: await getShowCommitOrStashFileStepItems(state),
matchOnDescription: true,
// additionalButtons: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
// additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickItemButton: (quickpick, button, _item) => {
if (button === QuickCommandButtons.SearchInSideBar) {
void Container.instance.searchAndCompareView.search(
state.repo.path,
{ pattern: SearchPattern.fromCommit(state.reference.ref) },
{
label: { label: `for ${GitReference.toString(state.reference, { icon: false })}` },
reveal: {
switch (button) {
case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else {
void GitActions.Commit.showDetailsView(state.reference, { pin: false, preserveFocus: true });
}
break;
case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
},
},
);
return;
}
if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
});
} else {
void GitActions.Commit.reveal(state.reference, {
select: true,
focus: false,
expand: true,
});
}
break;
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
@ -1988,7 +1910,9 @@ async function getShowCommitOrStashFileStepItems<
const file = await state.reference.findFile(state.fileName);
if (file == null) return [];
const items: (CommandQuickPickItem | QuickPickSeparator)[] = [];
const items: (CommandQuickPickItem | QuickPickSeparator)[] = [
new CommitOpenDetailsCommandQuickPickItem(state.reference),
];
if (isStash(state.reference)) {
items.push(

+ 4
- 7
src/quickpicks/items/commits.ts View File

@ -7,7 +7,6 @@ import { Commands, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { CommitFormatter } from '../../git/formatters/commitFormatter';
import type { GitCommit } from '../../git/models/commit';
import { isStash } from '../../git/models/commit';
import type { GitFileChange } from '../../git/models/file';
import { GitFile } from '../../git/models/file';
import type { GitStatusFile } from '../../git/models/status';
@ -47,9 +46,7 @@ export class CommitFilesQuickPickItem extends CommandQuickPickItem {
}${options?.hint != null ? `${pad(GlyphChars.Dash, 4, 2, GlyphChars.Space)}${options.hint}` : ''}`,
alwaysShow: true,
picked: options?.picked ?? true,
buttons: isStash(commit)
? [QuickCommandButtons.RevealInSideBar]
: [QuickCommandButtons.RevealInSideBar, QuickCommandButtons.SearchInSideBar],
buttons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
},
undefined,
undefined,
@ -258,11 +255,11 @@ export class CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem extends C
export class CommitOpenDetailsCommandQuickPickItem extends CommandQuickPickItem {
constructor(private readonly commit: GitCommit, item?: QuickPickItem) {
super(item ?? '$(files) Open in Commit Details');
super(item ?? '$(eye) Show Details');
}
override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.showDetailsView(this.commit);
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.showDetailsView(this.commit, { preserveFocus: options?.preserveFocus });
}
}

+ 4
- 1
src/quickpicks/referencePicker.ts View File

@ -139,7 +139,10 @@ export namespace ReferencePicker {
} else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, expand: true });
} else if (GitReference.isRevision(item)) {
void GitActions.Commit.reveal(item, { select: true, expand: true });
void GitActions.Commit.showDetailsView(item, {
pin: false,
preserveFocus: true,
});
}
}
}),

Loading…
Cancel
Save