Skip to content

Commit

Permalink
Fixes VFW not opening commit file quickpick
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Mar 25, 2022
1 parent f6e934e commit a97c94d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- Fixes an issue where the Visual File History wasn't correctly opening the commit file details quick pick menu
- Fixes an issue where the _Open Visual File History of Active File_ command wasn't showing in the Command Palette

## [12.0.3] - 2022-03-10
Expand Down
14 changes: 7 additions & 7 deletions src/commands/showQuickCommitFile.ts
Expand Up @@ -44,7 +44,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
args.sha = context.node.uri.sha;

if (isCommandContextViewNodeHasCommit(context)) {
args.commit = context.node.commit as any;
args.commit = context.node.commit;
}
}

Expand All @@ -58,21 +58,21 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
args = { ...args };

let gitUri;
if (args.revisionUri !== undefined) {
if (args.revisionUri != null) {
gitUri = GitUri.fromRevisionUri(Uri.parse(args.revisionUri, true));
args.sha = gitUri.sha;
} else {
gitUri = await GitUri.fromUri(uri);
}

if (args.sha === undefined) {
if (args.sha == null) {
if (editor == null) return;

const blameline = editor.selection.active.line;
if (blameline < 0) return;
const blameLine = editor.selection.active.line;
if (blameLine < 0) return;

try {
const blame = await this.container.git.getBlameForLine(gitUri, blameline);
const blame = await this.container.git.getBlameForLine(gitUri, blameLine);
if (blame == null) {
void Messages.showFileNotUnderSourceControlWarningMessage('Unable to show commit file details');

Expand All @@ -90,7 +90,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {

args.commit = blame.commit;
} catch (ex) {
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameline})`);
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameLine})`);
void window.showErrorMessage('Unable to show commit file details. See output channel for more details');

return;
Expand Down
6 changes: 3 additions & 3 deletions src/git/gitProviderService.ts
Expand Up @@ -901,10 +901,10 @@ export class GitProviderService implements Disposable {
}

getRevisionUri(uri: GitUri): Uri;
getRevisionUri(ref: string, path: string, repoPath: string): Uri;
getRevisionUri(ref: string, file: GitFile, repoPath: string): Uri;
getRevisionUri(ref: string, path: string, repoPath: string | Uri): Uri;
getRevisionUri(ref: string, file: GitFile, repoPath: string | Uri): Uri;
@log()
getRevisionUri(refOrUri: string | GitUri, pathOrFile?: string | GitFile, repoPath?: string): Uri {
getRevisionUri(refOrUri: string | GitUri, pathOrFile?: string | GitFile, repoPath?: string | Uri): Uri {
let path: string;
let ref: string | undefined;

Expand Down
12 changes: 7 additions & 5 deletions src/plus/webviews/timeline/timelineWebview.ts
@@ -1,6 +1,6 @@
'use strict';
import { commands, Disposable, TextEditor, Uri, ViewColumn, window } from 'vscode';
import type { ShowQuickCommitCommandArgs } from '../../../commands';
import type { ShowQuickCommitFileCommandArgs } from '../../../commands';
import { configuration } from '../../../configuration';
import { Commands, ContextKeys } from '../../../constants';
import type { Container } from '../../../container';
Expand All @@ -12,6 +12,7 @@ import { createFromDateDelta } from '../../../system/date';
import { debug } from '../../../system/decorators/log';
import { debounce, Deferrable } from '../../../system/function';
import { filter } from '../../../system/iterable';
import { getBestPath } from '../../../system/path';
import { hasVisibleTextEditor, isTextEditor } from '../../../system/utils';
import { IpcMessage, onIpc } from '../../../webviews/protocol';
import { WebviewBase } from '../../../webviews/webviewBase';
Expand Down Expand Up @@ -146,12 +147,13 @@ export class TimelineWebview extends WebviewBase<State> {
const repository = this.container.git.getRepository(this._context.uri);
if (repository == null) return;

const commandArgs: ShowQuickCommitCommandArgs = {
repoPath: repository.path,
sha: params.data.id,
const commandArgs: ShowQuickCommitFileCommandArgs = {
revisionUri: this.container.git
.getRevisionUri(params.data.id, getBestPath(this._context.uri), repository.uri)
.toString(true),
};

void commands.executeCommand(Commands.ShowQuickCommit, commandArgs);
void commands.executeCommand(Commands.ShowQuickCommitFile, commandArgs);

// const commandArgs: DiffWithPreviousCommandArgs = {
// line: 0,
Expand Down
12 changes: 7 additions & 5 deletions src/plus/webviews/timeline/timelineWebviewView.ts
@@ -1,6 +1,6 @@
'use strict';
import { commands, Disposable, TextEditor, Uri, window } from 'vscode';
import type { ShowQuickCommitCommandArgs } from '../../../commands';
import type { ShowQuickCommitFileCommandArgs } from '../../../commands';
import { configuration } from '../../../configuration';
import { Commands } from '../../../constants';
import { Container } from '../../../container';
Expand All @@ -12,6 +12,7 @@ import { createFromDateDelta } from '../../../system/date';
import { debug } from '../../../system/decorators/log';
import { debounce, Deferrable } from '../../../system/function';
import { filter } from '../../../system/iterable';
import { getBestPath } from '../../../system/path';
import { hasVisibleTextEditor, isTextEditor } from '../../../system/utils';
import { IpcMessage, onIpc } from '../../../webviews/protocol';
import { WebviewViewBase } from '../../../webviews/webviewViewBase';
Expand Down Expand Up @@ -123,12 +124,13 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
const repository = this.container.git.getRepository(this._context.uri);
if (repository == null) return;

const commandArgs: ShowQuickCommitCommandArgs = {
repoPath: repository.path,
sha: params.data.id,
const commandArgs: ShowQuickCommitFileCommandArgs = {
revisionUri: this.container.git
.getRevisionUri(params.data.id, getBestPath(this._context.uri), repository.uri)
.toString(true),
};

void commands.executeCommand(Commands.ShowQuickCommit, commandArgs);
void commands.executeCommand(Commands.ShowQuickCommitFile, commandArgs);

// const commandArgs: DiffWithPreviousCommandArgs = {
// line: 0,
Expand Down

0 comments on commit a97c94d

Please sign in to comment.