mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-16 17:25:40 -05:00
Fixes #34 - Open file should open the selected version of the file
Renames current Open File command to Open Working File Renames current Open Files command to Open Working Files Adds new Open File command to open the commit version of the file Adds new Open Files command to open the commit version of the files
This commit is contained in:
@@ -12,10 +12,21 @@ export { CommandQuickPickItem, CommitWithFileStatusQuickPickItem };
|
||||
|
||||
export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = GitProvider.toGitContentUri(commit);
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 as of \u00a0 $(git-commit) \u00a0 ${commit.sha} \u00a0\u2022\u00a0 ${commit.getFormattedPath()}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = Uri.file(path.resolve(commit.repoPath, commit.fileName));
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open Working Tree File`,
|
||||
label: `$(file-symlink-file) Open Working File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.getFormattedPath()}`
|
||||
});
|
||||
}
|
||||
@@ -24,12 +35,25 @@ export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPick
|
||||
export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitLogCommit, item?: QuickPickItem) {
|
||||
const repoPath = commit.repoPath;
|
||||
const uris = commit.fileStatuses.map(_ => GitProvider.toGitContentUri(commit.sha, _.fileName, repoPath, commit.originalFileName));
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Files`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 as of \u00a0 $(git-commit) \u00a0 ${commit.sha}`
|
||||
//detail: `Opens all of the changed files in $(git-commit) ${commit.sha}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitLogCommit, versioned: boolean = false, item?: QuickPickItem) {
|
||||
const repoPath = commit.repoPath;
|
||||
const uris = commit.fileStatuses.map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Working Tree Files`,
|
||||
description: undefined,
|
||||
detail: `Opens all of the files in commit $(git-commit) ${commit.sha}`
|
||||
label: `$(file-symlink-file) Open Working Files`,
|
||||
description: undefined
|
||||
//detail: `Opens all of the changed file in the working tree`
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -49,7 +73,8 @@ export class CommitDetailsQuickPick {
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.message}`
|
||||
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
|
||||
|
||||
items.splice(2, 0, new OpenCommitFilesCommandQuickPickItem(commit));
|
||||
items.splice(2, 0, new OpenCommitWorkingTreeFilesCommandQuickPickItem(commit));
|
||||
items.splice(3, 0, new OpenCommitFilesCommandQuickPickItem(commit));
|
||||
|
||||
if (goBackCommand) {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
@@ -117,6 +142,7 @@ export class CommitFileDetailsQuickPick {
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.message}`
|
||||
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
|
||||
|
||||
items.push(new OpenCommitWorkingTreeFileCommandQuickPickItem(commit));
|
||||
items.push(new OpenCommitFileCommandQuickPickItem(commit));
|
||||
|
||||
if (options.showFileHistory) {
|
||||
|
||||
Reference in New Issue
Block a user