diff --git a/package.json b/package.json index 2c961f0..653af2d 100644 --- a/package.json +++ b/package.json @@ -2227,6 +2227,11 @@ "category": "GitLens" }, { + "command": "gitlens.revealCommitInView", + "title": "Reveal Commit in Repositories View", + "category": "GitLens" + }, + { "command": "gitlens.showCommitInView", "title": "Show Commit in Search Commits View", "category": "GitLens" @@ -3409,6 +3414,10 @@ "when": "gitlens:enabled" }, { + "command": "gitlens.revealCommitInView", + "when": "gitlens:activeFileStatus =~ /blameable/" + }, + { "command": "gitlens.showCommitInView", "when": "gitlens:activeFileStatus =~ /blameable/" }, @@ -4716,11 +4725,16 @@ "group": "2_gitlens_quickopen_@2" }, { - "command": "gitlens.showCommitInView", + "command": "gitlens.revealCommitInView", "when": "viewItem =~ /gitlens:commit\\b/", "group": "3_gitlens_explore@1" }, { + "command": "gitlens.showCommitInView", + "when": "viewItem =~ /gitlens:commit\\b/", + "group": "3_gitlens_explore@2" + }, + { "command": "gitlens.openCommitInRemote", "when": "viewItem =~ /gitlens:commit\\b/ && gitlens:hasRemotes", "group": "5_gitlens_open@1" @@ -4830,11 +4844,16 @@ "group": "3_gitlens_explore@4" }, { - "command": "gitlens.showCommitInView", + "command": "gitlens.revealCommitInView", "when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/", "group": "3_gitlens_explore@3" }, { + "command": "gitlens.showCommitInView", + "when": "viewItem =~ /gitlens:file\\b(?!(:stash|:status))/", + "group": "3_gitlens_explore@4" + }, + { "command": "gitlens.openFileInRemote", "when": "viewItem =~ /gitlens:file\\b/ && gitlens:hasRemotes", "group": "5_gitlens_open@1" diff --git a/src/commands/common.ts b/src/commands/common.ts index f1995a4..fe00cc6 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -71,6 +71,7 @@ export enum Commands { PushRepositories = 'gitlens.pushRepositories', GitCommands = 'gitlens.gitCommands', ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings', + RevealCommitInView = 'gitlens.revealCommitInView', ShowCommitInView = 'gitlens.showCommitInView', SearchCommits = 'gitlens.showCommitSearch', SearchCommitsInView = 'gitlens.views.search.searchCommits', diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index ca5a4c1..130bc5d 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -20,7 +20,7 @@ export interface ShowQuickCommitDetailsCommandArgs { sha?: string; commit?: GitCommit | GitLogCommit; repoLog?: GitLog; - showInView?: boolean; + showInView?: 'reveal' | 'show'; goBackCommand?: CommandQuickPickItem; } @@ -38,13 +38,16 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { } constructor() { - super([Commands.ShowCommitInView, Commands.ShowQuickCommitDetails]); + super([Commands.RevealCommitInView, Commands.ShowCommitInView, Commands.ShowQuickCommitDetails]); } protected preExecute(context: CommandContext, args?: ShowQuickCommitDetailsCommandArgs) { - if (context.command === Commands.ShowCommitInView) { + if (context.command === Commands.RevealCommitInView) { args = { ...args }; - args.showInView = true; + args.showInView = 'reveal'; + } else if (context.command === Commands.ShowCommitInView) { + args = { ...args }; + args.showInView = 'show'; } if (context.type === 'viewItem') { @@ -120,13 +123,21 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { } if (args.showInView) { - void (await Container.searchView.search( - repoPath!, - { pattern: SearchPattern.fromCommit(args.commit) }, - { - label: { label: `for commit id ${args.commit.shortSha}` } - } - )); + if (args.showInView === 'reveal') { + void (await Container.repositoriesView.revealCommit(args.commit, { + select: true, + focus: true, + expand: true + })); + } else { + void (await Container.searchView.search( + repoPath!, + { pattern: SearchPattern.fromCommit(args.commit) }, + { + label: { label: `for commit id ${args.commit.shortSha}` } + } + )); + } return undefined; }