From af24943a41329f1ad9970e5725771fea4e5c6511 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Mon, 27 Feb 2023 15:32:57 -0500 Subject: [PATCH] Fixes #2527 shows added files for Open All Changes --- src/git/actions/commit.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/git/actions/commit.ts b/src/git/actions/commit.ts index b53abc9..0771146 100644 --- a/src/git/actions/commit.ts +++ b/src/git/actions/commit.ts @@ -202,8 +202,10 @@ export async function openChanges( commitOrRefs: GitCommit | { repoPath: string; ref1: string; ref2: string }, options?: TextDocumentShowOptions, ) { + const isArgCommit = isCommit(commitOrRefs); + if (typeof file === 'string') { - if (!isCommit(commitOrRefs)) throw new Error('Invalid arguments'); + if (!isArgCommit) throw new Error('Invalid arguments'); const f = await commitOrRefs.findFile(file); if (f == null) throw new Error('Invalid arguments'); @@ -213,17 +215,17 @@ export async function openChanges( options = { preserveFocus: true, preview: false, ...options }; - if (file.status === 'A') { - if (!isCommit(commitOrRefs)) return; - + if (file.status === 'A' && isArgCommit) { const commit = await commitOrRefs.getCommitForFile(file); void executeCommand(Commands.DiffWithPrevious, { commit: commit, showOptions: options, }); + + return; } - const refs = isCommit(commitOrRefs) + const refs = isArgCommit ? { repoPath: commitOrRefs.repoPath, // Don't need to worry about verifying the previous sha, as the DiffWith command will