Browse Source

Fixes diff issues with Commit Details view

Refs #2195
main
Eric Amodio 2 years ago
parent
commit
ac4b7625f9
2 changed files with 28 additions and 23 deletions
  1. +3
    -1
      CHANGELOG.md
  2. +25
    -22
      src/webviews/commitDetails/commitDetailsWebviewView.ts

+ 3
- 1
CHANGELOG.md View File

@ -16,7 +16,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes Commit Details showing incorrect actions for uncommitted changes
- Fixes [#2195](https://github.com/gitkraken/vscode-gitlens/issues/2195) - Cannot open new files from commit details
- Fixes Commit Details view showing incorrect diffs for certain commits
- Fixes Commit Details view showing incorrect actions for uncommitted changes
- Fixes prioritization of multiple PRs associated with the same commit to choose a merged PR over others
- Fixes Graph not showing account banners when access is not allowed and trial banners were previously dimissed
- Fixes [#2195](https://github.com/gitkraken/vscode-gitlens/issues/2195) - cannot open new files from commit details

+ 25
- 22
src/webviews/commitDetails/commitDetailsWebviewView.ts View File

@ -621,8 +621,11 @@ export class CommitDetailsWebviewView extends WebviewViewBase
};
}
private async getFileFromParams(params: FileActionParams): Promise<GitFileChange | undefined> {
return this._context.commit?.findFile(params.path);
private async getFileCommitFromParams(
params: FileActionParams,
): Promise<[commit: GitCommit, file: GitFileChange] | undefined> {
const commit = await this._context.commit?.getCommitForFile(params.path);
return commit != null ? [commit, commit.file!] : undefined;
}
private showAutolinkSettings() {
@ -651,23 +654,23 @@ export class CommitDetailsWebviewView extends WebviewViewBase
}
private async showFileActions(params: FileActionParams) {
if (this._context.commit == null) return;
const result = await this.getFileCommitFromParams(params);
if (result == null) return;
const file = await this.getFileFromParams(params);
if (file == null) return;
const [commit, file] = result;
this.updatePinned(true, true);
void GitActions.Commit.showDetailsQuickPick(this._context.commit, file);
void GitActions.Commit.showDetailsQuickPick(commit, file);
}
private async openFileComparisonWithWorking(params: FileActionParams) {
if (this._context.commit == null) return;
const result = await this.getFileCommitFromParams(params);
if (result == null) return;
const file = await this.getFileFromParams(params);
if (file == null) return;
const [commit, file] = result;
this.updatePinned(true, true);
void GitActions.Commit.openChangesWithWorking(file.path, this._context.commit, {
void GitActions.Commit.openChangesWithWorking(file.path, commit, {
preserveFocus: true,
preview: true,
...params.showOptions,
@ -675,13 +678,13 @@ export class CommitDetailsWebviewView extends WebviewViewBase
}
private async openFileComparisonWithPrevious(params: FileActionParams) {
if (this._context.commit == null) return;
const result = await this.getFileCommitFromParams(params);
if (result == null) return;
const file = await this.getFileFromParams(params);
if (file == null) return;
const [commit, file] = result;
this.updatePinned(true, true);
void GitActions.Commit.openChanges(file.path, this._context.commit, {
void GitActions.Commit.openChanges(file.path, commit, {
preserveFocus: true,
preview: true,
...params.showOptions,
@ -689,13 +692,13 @@ export class CommitDetailsWebviewView extends WebviewViewBase
}
private async openFile(params: FileActionParams) {
if (this._context.commit == null) return;
const result = await this.getFileCommitFromParams(params);
if (result == null) return;
const file = await this.getFileFromParams(params);
if (file == null) return;
const [commit, file] = result;
this.updatePinned(true, true);
void GitActions.Commit.openFile(file.path, this._context.commit, {
void GitActions.Commit.openFile(file.path, commit, {
preserveFocus: true,
preview: true,
...params.showOptions,
@ -703,12 +706,12 @@ export class CommitDetailsWebviewView extends WebviewViewBase
}
private async openFileOnRemote(params: FileActionParams) {
if (this._context.commit == null) return;
const result = await this.getFileCommitFromParams(params);
if (result == null) return;
const file = await this.getFileFromParams(params);
if (file == null) return;
const [commit, file] = result;
void GitActions.Commit.openFileOnRemote(file.path, this._context.commit);
void GitActions.Commit.openFileOnRemote(file.path, commit);
}
}

Loading…
Cancel
Save