diff --git a/CHANGELOG.md b/CHANGELOG.md index cc53402..b31e14b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Indicates which branch is the current branch and optionally shows the remote tracking branch - Expand each branch to easily see its revision (commit) history - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands - - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands + - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, `Show File History`, and `Show Commit File Details` commands + - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, and `Refresh` commands - Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands - Provides a context menu with `Open Branches in Remote`, and `Refresh` commands @@ -36,15 +36,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Expand each branch to easily see its revision (commit) history - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands - - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands + - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`,`Show Commit Details`, and `Refresh` commands - Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, and `Refresh` commands - Provides a context menu with a `Refresh` command - `Stashes` node — provides a list of stashed changes - Expand each stash to quickly see the set of files stashed, complete with status indicators for adds, changes, renames, and deletes - Provides a context menu with `Stash Changes`, and `Refresh` commands - - Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, and `Refresh` commands - - Provides a context menu on each stashed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Apply Changes`, and `Show File History` commands + - Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit Message to Clipboard`, and `Refresh` commands + - Provides a context menu on each stashed file with `Apply Changes`, `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, and `Show File History` commands - `History View` - provides the revision history of the active file diff --git a/README.md b/README.md index b0a793e..67eff20 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,8 @@ GitLens provides an unobtrusive blame annotation at the end of the current line, - Expand each branch to easily see its revision (commit) history - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands - - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands + + - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, and `Refresh` commands - Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands - Provides a context menu with `Open Branches in Remote`, and `Refresh` commands @@ -147,16 +148,16 @@ GitLens provides an unobtrusive blame annotation at the end of the current line, - Expand each remote to see its list of branches - Expand each branch to easily see its revision (commit) history - Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes - - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands - - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands + - Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, `Show File History`, and `Show Commit File Details` commands + - Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`,`Show Commit Details`, and `Refresh` commands - Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, and `Refresh` commands - Provides a context menu with a `Refresh` command - `Stashes` node — provides a list of stashed changes - Expand each stash to quickly see the set of files stashed, complete with status indicators for adds, changes, renames, and deletes - Provides a context menu with `Stash Changes`, and `Refresh` commands - - Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, and `Refresh` commands - - Provides a context menu on each stashed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Apply Changes`, and `Show File History` commands + - Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit Message to Clipboard`, and `Refresh` commands + - Provides a context menu on each stashed file with `Apply Changes`, `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, and `Show File History` commands - `History View` - provides the revision history of the active file diff --git a/package.json b/package.json index 93d4072..ba2a71d 100644 --- a/package.json +++ b/package.json @@ -1094,6 +1094,16 @@ "title": "Open Files", "category": "GitLens" }, + { + "command": "gitlens.gitExplorer.openChangedFileChanges", + "title": "Open All Changes", + "category": "GitLens" + }, + { + "command": "gitlens.gitExplorer.openChangedFileChangesWithWorking", + "title": "Open All Changes with Working Tree", + "category": "GitLens" + }, { "command": "gitlens.gitExplorer.openChangedFileRevisions", "title": "Open Revisions", @@ -1299,6 +1309,14 @@ "command": "gitlens.gitExplorer.openChangedFiles", "when": "false" }, + { + "command": "gitlens.gitExplorer.openChangedFileChanges", + "when": "false" + }, + { + "command": "gitlens.gitExplorer.openChangedFileChangesWithWorking", + "when": "false" + }, { "command": "gitlens.gitExplorer.openChangedFileRevisions", "when": "false" @@ -1504,204 +1522,224 @@ "view/title": [ { "command": "gitlens.showCommitSearch", - "when": "gitlens:enabled && view == gitlens.gitExplorer", + "when": "view == gitlens.gitExplorer", "group": "navigation@1" }, { "command": "gitlens.gitExplorer.switchToHistoryView", - "when": "gitlens:enabled && view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository", + "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository", "group": "navigation@2" }, { "command": "gitlens.gitExplorer.switchToRepositoryView", - "when": "gitlens:enabled && view == gitlens.gitExplorer && gitlens:gitExplorer:view == history", + "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history", "group": "navigation@3" }, { "command": "gitlens.gitExplorer.refresh", - "when": "gitlens:enabled && view == gitlens.gitExplorer", + "when": "view == gitlens.gitExplorer", "group": "navigation@4" } ], "view/item/context": [ { "command": "gitlens.openBranchesInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches:remote", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:branches:remote", "group": "1_gitlens@1" }, { "command": "gitlens.openBranchInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history:remote", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:branch-history:remote", "group": "1_gitlens@1" }, { "command": "gitlens.openCommitInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "1_gitlens@1" }, { - "command": "gitlens.copyShaToClipboard", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit", + "command": "gitlens.gitExplorer.openChangedFileChanges", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "2_gitlens@1" }, { - "command": "gitlens.copyMessageToClipboard", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit", - "group": "2_gitlens@2" + "command": "gitlens.gitExplorer.openChangedFileChangesWithWorking", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", + "group": "2_gitlens@1" }, { "command": "gitlens.gitExplorer.openChangedFiles", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "3_gitlens@1" }, { "command": "gitlens.gitExplorer.openChangedFileRevisions", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "3_gitlens@2" }, { - "command": "gitlens.showQuickCommitDetails", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit", + "command": "gitlens.copyShaToClipboard", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", "group": "4_gitlens@1" }, + { + "command": "gitlens.copyMessageToClipboard", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", + "group": "4_gitlens@2" + }, + { + "command": "gitlens.showQuickCommitDetails", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit", + "group": "5_gitlens@1" + }, { "command": "gitlens.gitExplorer.openChanges", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "1_gitlens@1" }, { "command": "gitlens.gitExplorer.openChangesWithWorking", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "1_gitlens@2" }, { "command": "gitlens.gitExplorer.openFile", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "2_gitlens@1" }, { "command": "gitlens.gitExplorer.openFileRevision", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "2_gitlens@2" }, { "command": "gitlens.openFileInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "3_gitlens@1" }, { "command": "gitlens.gitExplorer.openFileRevisionInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "3_gitlens@2" }, { "command": "gitlens.gitExplorer.applyChanges", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "4_gitlens@1" }, { "command": "gitlens.showQuickFileHistory", - "when": "gitlens:isTracked && view == gitlens.gitExplorer && viewItem == gitlens:commit-file && gitlens:gitExplorer:view == repository", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file && gitlens:gitExplorer:view == repository", "group": "5_gitlens@1" }, { "command": "gitlens.showQuickCommitFileDetails", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:commit-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:commit-file", "group": "5_gitlens@2" }, { "command": "gitlens.gitExplorer.openFile", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:file-history", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:file-history", "group": "1_gitlens@1" }, { "command": "gitlens.openFileInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:file-history", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:file-history", "group": "1_gitlens@2" }, { "command": "gitlens.openBranchesInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", "group": "1_gitlens@1" }, { "command": "gitlens.openRepoInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:remote", "group": "1_gitlens@2" }, { "command": "gitlens.stashSave", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stashes", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stashes", "group": "1_gitlens@1" }, { "command": "gitlens.stashApply", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", "group": "1_gitlens@1" }, { "command": "gitlens.stashDelete", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", "group": "1_gitlens@2" }, { - "command": "gitlens.copyMessageToClipboard", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash", + "command": "gitlens.gitExplorer.openChangedFileChanges", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", + "group": "2_gitlens@1" + }, + { + "command": "gitlens.gitExplorer.openChangedFileChangesWithWorking", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", "group": "2_gitlens@1" }, { "command": "gitlens.gitExplorer.openChangedFiles", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", "group": "3_gitlens@1" }, { "command": "gitlens.gitExplorer.openChangedFileRevisions", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", "group": "3_gitlens@2" }, { - "command": "gitlens.gitExplorer.openChanges", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", - "group": "1_gitlens@1" - }, - { - "command": "gitlens.gitExplorer.openChangesWithWorking", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", - "group": "1_gitlens@2" - }, - { - "command": "gitlens.gitExplorer.openFile", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", - "group": "2_gitlens@1" - }, - { - "command": "gitlens.gitExplorer.openFileRevision", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", - "group": "2_gitlens@2" - }, - { - "command": "gitlens.openFileInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", - "group": "3_gitlens@1" + "command": "gitlens.copyMessageToClipboard", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash", + "group": "4_gitlens@1" }, { "command": "gitlens.gitExplorer.applyChanges", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "group": "1_gitlens@1" + }, + { + "command": "gitlens.gitExplorer.openChanges", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "group": "2_gitlens@1" + }, + { + "command": "gitlens.gitExplorer.openChangesWithWorking", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "group": "2_gitlens@2" + }, + { + "command": "gitlens.gitExplorer.openFile", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "group": "3_gitlens@1" + }, + { + "command": "gitlens.gitExplorer.openFileRevision", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "group": "3_gitlens@2" + }, + { + "command": "gitlens.openFileInRemote", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", "group": "4_gitlens@1" }, { "command": "gitlens.showQuickFileHistory", - "when": "gitlens:isTracked && view == gitlens.gitExplorer && viewItem == gitlens:stash-file", + "when": "view == gitlens.gitExplorer && viewItem == gitlens:stash-file", "group": "5_gitlens@1" }, { "command": "gitlens.openRepoInRemote", - "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:status", + "when": "gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:status", "group": "1_gitlens@1" }, { "command": "gitlens.gitExplorer.refresh", - "when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem != gitlens:commit-file && viewItem != gitlens:stash-file", + "when": "view == gitlens.gitExplorer && viewItem != gitlens:commit-file && viewItem != gitlens:stash-file", "group": "9_gitlens@1" } ] diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 623ec68..64936c0 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -101,26 +101,18 @@ export class DiffWithCommand extends ActiveEditorCommand { args.showOptions.selection = new Range(args.line, 0, args.line, 0); } - let lhsPrefix = ''; - if (lhs === undefined) { - lhsPrefix = 'deleted in '; - } - else if (args.rhs.sha === GitService.fakeSha) { - lhsPrefix = 'added in '; - } - let rhsPrefix = ''; if (rhs === undefined) { rhsPrefix = 'deleted in '; } - else if (args.lhs.sha === GitService.fakeSha) { + else if (lhs === undefined || args.lhs.sha === GitService.fakeSha) { rhsPrefix = 'added in '; } - if (args.lhs.title === undefined && args.lhs.sha !== GitService.fakeSha) { + if (args.lhs.title === undefined && lhs !== undefined && args.lhs.sha !== GitService.fakeSha) { args.lhs.title = (args.lhs.sha === '' || GitService.isUncommitted(args.lhs.sha)) ? `${path.basename(args.lhs.uri.fsPath)}` - : `${path.basename(args.lhs.uri.fsPath)} (${lhsPrefix}${GitService.shortenSha(args.lhs.sha)})`; + : `${path.basename(args.lhs.uri.fsPath)} (${GitService.shortenSha(args.lhs.sha)})`; } if (args.rhs.title === undefined && args.rhs.sha !== GitService.fakeSha) { args.rhs.title = (args.rhs.sha === '' || GitService.isUncommitted(args.rhs.sha)) diff --git a/src/git/git.ts b/src/git/git.ts index c4c0972..9ba025b 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -358,7 +358,8 @@ export class Git { return await gitCommand(opts, 'show', args); } catch (ex) { - if (/Path \'.*?\' does not exist in/.test(ex && ex.toString())) { + const msg = ex && ex.toString(); + if (/Path \'.*?\' does not exist in/.test(msg) || /Path \'.*?\' exists on disk, but not in /.test(msg)) { return undefined; } diff --git a/src/views/gitExplorer.ts b/src/views/gitExplorer.ts index 89ec27b..15ab3a0 100644 --- a/src/views/gitExplorer.ts +++ b/src/views/gitExplorer.ts @@ -1,7 +1,7 @@ 'use strict'; import { Functions, Objects } from '../system'; import { commands, Event, EventEmitter, ExtensionContext, TextDocumentShowOptions, TextEditor, TreeDataProvider, TreeItem, Uri, window, workspace } from 'vscode'; -import { Commands, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands'; +import { Commands, DiffWithCommandArgs, DiffWithCommandArgsRevision, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands'; import { UriComparer } from '../comparers'; import { ExtensionKey, IConfig } from '../configuration'; import { CommandContext, setCommandContext } from '../constants'; @@ -49,6 +49,8 @@ export class GitExplorer implements TreeDataProvider { commands.registerCommand('gitlens.gitExplorer.openFileRevision', this.openFileRevision, this); commands.registerCommand('gitlens.gitExplorer.openFileRevisionInRemote', this.openFileRevisionInRemote, this); commands.registerCommand('gitlens.gitExplorer.openChangedFiles', this.openChangedFiles, this); + commands.registerCommand('gitlens.gitExplorer.openChangedFileChanges', this.openChangedFileChanges, this); + commands.registerCommand('gitlens.gitExplorer.openChangedFileChangesWithWorking', this.openChangedFileChangesWithWorking, this); commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this); commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this); @@ -190,6 +192,29 @@ export class GitExplorer implements TreeDataProvider { return openEditor(options.uri || GitService.toGitContentUri(node.uri), options.showOptions || { preserveFocus: true, preview: false }); } + private async openChangedFileChanges(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) { + const repoPath = node.commit.repoPath; + const uris = node.commit.fileStatuses + .map(s => GitUri.fromFileStatus(s, repoPath)); + for (const uri of uris) { + await this.openDiffWith(repoPath, + { uri: uri, sha: node.commit.previousSha !== undefined ? node.commit.previousSha : GitService.fakeSha }, + { uri: uri, sha: node.commit.sha }, options); + } + } + + private async openChangedFileChangesWithWorking(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) { + const repoPath = node.commit.repoPath; + const uris = node.commit.fileStatuses + .filter(s => s.status !== 'D') + .map(s => GitUri.fromFileStatus(s, repoPath)); + for (const uri of uris) { + await this.openDiffWith(repoPath, + { uri: uri, sha: node.commit.sha }, + { uri: uri, sha: '' }, options); + } + } + private async openChangedFiles(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) { const repoPath = node.commit.repoPath; const uris = node.commit.fileStatuses.filter(s => s.status !== 'D').map(s => GitUri.fromFileStatus(s, repoPath)); @@ -207,6 +232,16 @@ export class GitExplorer implements TreeDataProvider { } } + private async openDiffWith(repoPath: string, lhs: DiffWithCommandArgsRevision, rhs: DiffWithCommandArgsRevision, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) { + const diffArgs: DiffWithCommandArgs = { + repoPath: repoPath, + lhs: lhs, + rhs: rhs, + showOptions: options + }; + return commands.executeCommand(Commands.DiffWith, diffArgs); + } + private async openFileRevisionInRemote(node: CommitNode | StashNode) { return commands.executeCommand(Commands.OpenFileInRemote, new GitUri(node.commit.uri, node.commit), { range: false } as OpenFileInRemoteCommandArgs); }