diff --git a/src/commands/common.ts b/src/commands/common.ts index 9f87897..5ee5277 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -405,9 +405,8 @@ export async function openEditor( if (uri.scheme === DocumentSchemes.GitLensGit) { const gitUri = GitUri.fromRevisionUri(uri); if (ImageExtensions.includes(path.extname(gitUri.fsPath))) { - const fileName = await Container.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha); - if (fileName !== undefined) { - uri = Uri.file(fileName); + const uri = await Container.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha); + if (uri !== undefined) { await commands.executeCommand(BuiltInCommands.Open, uri); return undefined; diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 0067049..7555ac1 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -164,10 +164,10 @@ export class DiffWithCommand extends ActiveEditorCommand { BuiltInCommands.Diff, lhs === undefined ? GitUri.toRevisionUri(GitService.deletedSha, args.lhs.uri.fsPath, args.repoPath) - : Uri.file(lhs), + : lhs, rhs === undefined ? GitUri.toRevisionUri(GitService.deletedSha, args.rhs.uri.fsPath, args.repoPath) - : Uri.file(rhs), + : rhs, title, args.showOptions ); diff --git a/src/gitService.ts b/src/gitService.ts index d219978..e6cd12f 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -1611,13 +1611,17 @@ export class GitService extends Disposable { return GitTagParser.parse(data, repoPath) || []; } - async getVersionedFile(repoPath: string | undefined, fileName: string, sha: string | undefined) { + async getVersionedFile( + repoPath: string | undefined, + fileName: string, + sha: string | undefined + ): Promise { Logger.log(`getVersionedFile('${repoPath}', '${fileName}', '${sha}')`); if (sha === GitService.deletedSha) return undefined; if (!sha || (Git.isUncommitted(sha) && !Git.isStagedUncommitted(sha))) { - if (await this.fileExists(repoPath!, fileName)) return fileName; + if (await this.fileExists(repoPath!, fileName)) return Uri.file(fileName); return undefined; } @@ -1630,7 +1634,7 @@ export class GitService extends Disposable { new GitUri(Uri.file(fileName), { sha: sha, repoPath: repoPath!, versionedPath: file }) ); - return file; + return Uri.file(file); } getVersionedFileText(repoPath: string, fileName: string, sha: string) {