瀏覽代碼

Changes behavior of CodeLens showQuickFileHistory

It now opens commit details directly
main
Eric Amodio 7 年之前
父節點
當前提交
af5b8b7e09
共有 3 個文件被更改,包括 21 次插入17 次删除
  1. +3
    -3
      src/commands/quickPicks.ts
  2. +15
    -11
      src/commands/showQuickFileHistory.ts
  3. +3
    -3
      src/gitCodeLensProvider.ts

+ 3
- 3
src/commands/quickPicks.ts 查看文件

@ -28,14 +28,14 @@ export class CommitQuickPick {
label: `$(versions) Show Previous Commit History`,
description: `\u2022 ${commit.fileName}`,
detail: `Shows the previous commit history starting at $(git-commit) ${commit.sha}`
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, undefined, currentCommand]));
if (workingFileName) {
items.push(new CommandQuickPickItem({
label: `$(versions) Show Commit History`,
description: `\u2022 ${commit.fileName}`,
detail: `Shows the commit history starting at the most recent commit`
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand]));
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, undefined, currentCommand]));
}
}
@ -80,7 +80,7 @@ export class FileCommitsQuickPick {
label: `$(sync) Show All Commits`,
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
detail: `This may take a while`
}, Commands.ShowQuickFileHistory, [uri, 0, goBackCommand]));
}, Commands.ShowQuickFileHistory, [uri, 0, undefined, goBackCommand]));
}
// Only show the full repo option if we are the root

+ 15
- 11
src/commands/showQuickFileHistory.ts 查看文件

@ -2,7 +2,7 @@
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand } from './commands';
import { Commands } from '../constants';
import GitProvider, { GitUri } from '../gitProvider';
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
import { Logger } from '../logger';
import { CommandQuickPickItem } from './quickPickItems';
import { FileCommitsQuickPick } from './quickPicks';
@ -13,7 +13,7 @@ export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
super(Commands.ShowQuickFileHistory);
}
async execute(editor: TextEditor, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem) {
async execute(editor: TextEditor, uri?: Uri, maxCount?: number, commit?: GitCommit, goBackCommand?: CommandQuickPickItem) {
if (!(uri instanceof Uri)) {
if (!editor || !editor.document) return undefined;
uri = editor.document.uri;
@ -26,23 +26,27 @@ export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
}
try {
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, maxCount);
if (!log) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
if (!commit) {
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, maxCount);
if (!log) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
let pick = await FileCommitsQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
if (!pick) return undefined;
let pick = await FileCommitsQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
if (pick instanceof CommandQuickPickItem) {
return pick.execute();
}
commit = pick.commit;
}
return commands.executeCommand(Commands.ShowQuickCommitDetails,
new GitUri(pick.commit.uri, pick.commit),
pick.commit.sha, pick.commit,
new GitUri(commit.uri, commit),
commit.sha, commit,
new CommandQuickPickItem({
label: `go back \u21A9`,
description: null
}, Commands.ShowQuickFileHistory, [uri, maxCount, goBackCommand]),
}, Commands.ShowQuickFileHistory, [uri, maxCount, undefined, goBackCommand]),
{ showFileHistory: false });
}
catch (ex) {

+ 3
- 3
src/gitCodeLensProvider.ts 查看文件

@ -212,7 +212,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
case CodeLensCommand.ShowBlameHistory: return this._applyShowBlameHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
case CodeLensCommand.ShowFileHistory: return this._applyShowFileHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
case CodeLensCommand.DiffWithPrevious: return this._applyDiffWithPreviousCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
case CodeLensCommand.ShowQuickFileHistory: return this._applyShowQuickFileHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame);
case CodeLensCommand.ShowQuickFileHistory: return this._applyShowQuickFileHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
default: return lens;
}
}
@ -295,11 +295,11 @@ export default class GitCodeLensProvider implements CodeLensProvider {
return lens;
}
_applyShowQuickFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines): T {
_applyShowQuickFileHistoryCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(title: string, lens: T, blame: IGitBlameLines, commit?: GitCommit): T {
lens.command = {
title: title,
command: CodeLensCommand.ShowQuickFileHistory,
arguments: [Uri.file(lens.uri.fsPath)]
arguments: [Uri.file(lens.uri.fsPath), undefined, commit]
};
return lens;
}

Loading…
取消
儲存