mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Changes behavior of CodeLens showQuickFileHistory
It now opens commit details directly
This commit is contained in:
@@ -28,14 +28,14 @@ export class CommitQuickPick {
|
|||||||
label: `$(versions) Show Previous Commit History`,
|
label: `$(versions) Show Previous Commit History`,
|
||||||
description: `\u2022 ${commit.fileName}`,
|
description: `\u2022 ${commit.fileName}`,
|
||||||
detail: `Shows the previous commit history starting at $(git-commit) ${commit.sha}`
|
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) {
|
if (workingFileName) {
|
||||||
items.push(new CommandQuickPickItem({
|
items.push(new CommandQuickPickItem({
|
||||||
label: `$(versions) Show Commit History`,
|
label: `$(versions) Show Commit History`,
|
||||||
description: `\u2022 ${commit.fileName}`,
|
description: `\u2022 ${commit.fileName}`,
|
||||||
detail: `Shows the commit history starting at the most recent commit`
|
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`,
|
label: `$(sync) Show All Commits`,
|
||||||
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
|
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
|
||||||
detail: `This may take a while`
|
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
|
// Only show the full repo option if we are the root
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand } from './commands';
|
||||||
import { Commands } from '../constants';
|
import { Commands } from '../constants';
|
||||||
import GitProvider, { GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem } from './quickPickItems';
|
import { CommandQuickPickItem } from './quickPickItems';
|
||||||
import { FileCommitsQuickPick } from './quickPicks';
|
import { FileCommitsQuickPick } from './quickPicks';
|
||||||
@@ -13,7 +13,7 @@ export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
|||||||
super(Commands.ShowQuickFileHistory);
|
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 (!(uri instanceof Uri)) {
|
||||||
if (!editor || !editor.document) return undefined;
|
if (!editor || !editor.document) return undefined;
|
||||||
uri = editor.document.uri;
|
uri = editor.document.uri;
|
||||||
@@ -26,23 +26,27 @@ export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, maxCount);
|
if (!commit) {
|
||||||
if (!log) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
|
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);
|
let pick = await FileCommitsQuickPick.show(log, uri, maxCount, this.git.config.advanced.maxQuickHistory, goBackCommand);
|
||||||
if (!pick) return undefined;
|
if (!pick) return undefined;
|
||||||
|
|
||||||
if (pick instanceof CommandQuickPickItem) {
|
if (pick instanceof CommandQuickPickItem) {
|
||||||
return pick.execute();
|
return pick.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
commit = pick.commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return commands.executeCommand(Commands.ShowQuickCommitDetails,
|
return commands.executeCommand(Commands.ShowQuickCommitDetails,
|
||||||
new GitUri(pick.commit.uri, pick.commit),
|
new GitUri(commit.uri, commit),
|
||||||
pick.commit.sha, pick.commit,
|
commit.sha, commit,
|
||||||
new CommandQuickPickItem({
|
new CommandQuickPickItem({
|
||||||
label: `go back \u21A9`,
|
label: `go back \u21A9`,
|
||||||
description: null
|
description: null
|
||||||
}, Commands.ShowQuickFileHistory, [uri, maxCount, goBackCommand]),
|
}, Commands.ShowQuickFileHistory, [uri, maxCount, undefined, goBackCommand]),
|
||||||
{ showFileHistory: false });
|
{ showFileHistory: false });
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
|
|||||||
case CodeLensCommand.ShowBlameHistory: return this._applyShowBlameHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
|
case CodeLensCommand.ShowBlameHistory: return this._applyShowBlameHistoryCommand<GitRecentChangeCodeLens>(title, lens, blame, recentCommit);
|
||||||
case CodeLensCommand.ShowFileHistory: return this._applyShowFileHistoryCommand<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.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;
|
default: return lens;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,11 +295,11 @@ export default class GitCodeLensProvider implements CodeLensProvider {
|
|||||||
return lens;
|
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 = {
|
lens.command = {
|
||||||
title: title,
|
title: title,
|
||||||
command: CodeLensCommand.ShowQuickFileHistory,
|
command: CodeLensCommand.ShowQuickFileHistory,
|
||||||
arguments: [Uri.file(lens.uri.fsPath)]
|
arguments: [Uri.file(lens.uri.fsPath), undefined, commit]
|
||||||
};
|
};
|
||||||
return lens;
|
return lens;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user