From c2483200c936c3a6de888e11c70330e405f767ae Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 9 Dec 2018 23:59:21 -0500 Subject: [PATCH] Fixes the path of git: uris -- won't load content otherwise --- CHANGELOG.md | 1 + src/git/gitService.ts | 8 +------- src/git/gitUri.ts | 11 +++++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ee41e..a6aeea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Fixes an issue where gravatar icons would sometimes not show up — thanks to [PR #579](https://github.com/eamodio/vscode-gitlens/pull/579) by sgtwilko ([@sgtwilko](https://github.com/sgtwilko)) - Fixes [#501](https://github.com/eamodio/vscode-gitlens/issues/501) — Azure DevOps ssh remotes aren't handled properly - Fixes [#572](https://github.com/eamodio/vscode-gitlens/issues/572) — Explorer cant expand some branch folders +- Fixes an issue where comparing a file with its staged revision doesn't show any content ## [9.0.3] - 2018-12-06 diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 0b6c4f9..d7280da 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -1906,13 +1906,7 @@ export class GitService implements Disposable { } if (Git.isStagedUncommitted(ref)) { - const path = GitUri.resolve(fileName, repoPath); - return Uri.parse( - `git:${path}?${JSON.stringify({ - path: path, - ref: '~' - })}` - ); + return GitUri.git(fileName, repoPath); } return GitUri.toRevisionUri(ref, fileName, repoPath!); diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index f174379..6d02211 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -323,6 +323,17 @@ export class GitUri extends ((Uri as any) as UriEx) { return Strings.normalizePath(relativePath); } + static git(fileName: string, repoPath?: string) { + const path = GitUri.resolve(fileName, repoPath); + return Uri.parse( + `git:${path}?${JSON.stringify({ + // Ensure we use the fsPath here, otherwise the url won't open properly + path: Uri.file(path).fsPath, + ref: '~' + })}` + ); + } + static resolve(fileName: string, repoPath?: string) { const normalizedFileName = Strings.normalizePath(fileName); if (repoPath === undefined) return normalizedFileName;