diff --git a/src/commands/gitCommands.actions.ts b/src/commands/gitCommands.actions.ts index 37327a3..913331b 100644 --- a/src/commands/gitCommands.actions.ts +++ b/src/commands/gitCommands.actions.ts @@ -757,8 +757,11 @@ export namespace GitActions { })); } - export function showDetailsView(commit: GitCommit): Promise { - return Container.instance.commitDetailsView.show({ commit: commit }); + export function showDetailsView( + commit: GitCommit, + options?: { pin?: boolean; preserveFocus?: boolean }, + ): Promise { + return Container.instance.commitDetailsView.show({ ...options, commit: commit }); } } diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 996c822..b7617ab 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -3,6 +3,7 @@ import { commitNodeType, mergeNodeType, stashNodeType } from '@gitkraken/gitkrak import type { ColorTheme, ConfigurationChangeEvent, Disposable, Event, StatusBarItem } from 'vscode'; import { ColorThemeKind, EventEmitter, MarkdownString, StatusBarAlignment, Uri, ViewColumn, window } from 'vscode'; import { parseCommandContext } from '../../../commands/base'; +import { GitActions } from '../../../commands/gitCommands.actions'; import type { GraphColumnConfig } from '../../../configuration'; import { configuration } from '../../../configuration'; import { Commands } from '../../../constants'; @@ -210,6 +211,10 @@ export class GraphWebview extends WebviewBase { } this._onDidChangeSelection.fire({ selection: commits ?? [] }); + + if (commits == null) return; + + void GitActions.Commit.showDetailsView(commits[0], { pin: true, preserveFocus: true }); } private async notifyDidChangeConfig() { diff --git a/src/plus/webviews/timeline/timelineWebview.ts b/src/plus/webviews/timeline/timelineWebview.ts index cbfdd02..13a00bf 100644 --- a/src/plus/webviews/timeline/timelineWebview.ts +++ b/src/plus/webviews/timeline/timelineWebview.ts @@ -148,7 +148,7 @@ export class TimelineWebview extends WebviewBase { const commit = await repository.getCommit(params.data.id); if (commit == null) return; - void GitActions.Commit.showDetailsView(commit); + void GitActions.Commit.showDetailsView(commit, { pin: true, preserveFocus: true }); }); break; diff --git a/src/plus/webviews/timeline/timelineWebviewView.ts b/src/plus/webviews/timeline/timelineWebviewView.ts index 6da1d4b..12ba238 100644 --- a/src/plus/webviews/timeline/timelineWebviewView.ts +++ b/src/plus/webviews/timeline/timelineWebviewView.ts @@ -127,7 +127,7 @@ export class TimelineWebviewView extends WebviewViewBase { const commit = await repository.getCommit(params.data.id); if (commit == null) return; - void GitActions.Commit.showDetailsView(commit); + void GitActions.Commit.showDetailsView(commit, { pin: true, preserveFocus: true }); }); break; diff --git a/src/webviews/commitDetails/commitDetailsWebviewView.ts b/src/webviews/commitDetails/commitDetailsWebviewView.ts index e2b1ca4..99226f6 100644 --- a/src/webviews/commitDetails/commitDetailsWebviewView.ts +++ b/src/webviews/commitDetails/commitDetailsWebviewView.ts @@ -80,15 +80,20 @@ export class CommitDetailsWebviewView extends WebviewViewBase { + override async show(options?: { + commit?: GitCommit; + pin?: boolean; + preserveFocus?: boolean | undefined; + }): Promise { if (options != null) { let commit; - ({ commit, ...options } = options); + let pin; + ({ commit, pin, ...options } = options); if (commit == null) { commit = this.getBestCommit(); } if (commit != null) { - this.updateCommit(commit, { pinned: true }); + this.updateCommit(commit, { pinned: pin ?? true }); } } @@ -136,12 +141,11 @@ export class CommitDetailsWebviewView extends WebviewViewBase