diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index a2c0f8a..c636281 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -13,7 +13,6 @@ export interface GitCommitish { fileName?: string; repoPath: string; sha?: string; - versionedPath?: string; } interface UriComponents { @@ -43,7 +42,6 @@ export class GitUri extends (Uri as any as UriEx) { readonly repoPath?: string; readonly sha?: string; - readonly versionedPath?: string; constructor(uri?: Uri); constructor(uri: Uri, commit: GitCommitish); @@ -140,7 +138,6 @@ export class GitUri extends (Uri as any as UriEx) { fragment: uri.fragment, }); this.repoPath = commitOrRepoPath.repoPath; - this.versionedPath = commitOrRepoPath.versionedPath; if (GitRevision.isUncommittedStaged(commitOrRepoPath.sha) || !GitRevision.isUncommitted(commitOrRepoPath.sha)) { this.sha = commitOrRepoPath.sha; } @@ -181,12 +178,15 @@ export class GitUri extends (Uri as any as UriEx) { return GitRevision.shorten(this.sha); } - @memoize(useVersionedPath => `${useVersionedPath ? 'versioned' : ''}`) - documentUri(useVersionedPath: boolean = false) { - if (useVersionedPath && this.versionedPath != null) return GitUri.file(this.versionedPath); - if (this.scheme !== 'file') return this; - - return GitUri.file(this.fsPath); + @memoize() + documentUri() { + return Uri.from({ + scheme: this.scheme, + authority: this.authority, + path: this.path, + query: this.query, + fragment: this.fragment, + }); } equals(uri: Uri | undefined) { diff --git a/src/trackers/documentTracker.ts b/src/trackers/documentTracker.ts index f6b2aeb..8646401 100644 --- a/src/trackers/documentTracker.ts +++ b/src/trackers/documentTracker.ts @@ -286,7 +286,7 @@ export class DocumentTracker implements Disposable { let document; if (GitUri.is(documentOrId)) { try { - document = await workspace.openTextDocument(documentOrId.documentUri(true)); + document = await workspace.openTextDocument(documentOrId.documentUri()); } catch (ex) { const msg: string = ex?.toString() ?? ''; if (msg.includes('File seems to be binary and cannot be opened as text')) { @@ -319,7 +319,7 @@ export class DocumentTracker implements Disposable { private _get(documentOrId: string | TextDocument | Uri) { if (GitUri.is(documentOrId)) { - documentOrId = GitUri.toKey(documentOrId.documentUri(true)); + documentOrId = GitUri.toKey(documentOrId.documentUri()); } else if (typeof documentOrId === 'string' || documentOrId instanceof Uri) { documentOrId = GitUri.toKey(documentOrId); } @@ -426,7 +426,7 @@ class EmptyTextDocument implements TextDocument { readonly version: number; constructor(public readonly gitUri: GitUri) { - this.uri = gitUri.documentUri(true); + this.uri = gitUri.documentUri(); this.eol = EndOfLine.LF; this.fileName = this.uri.fsPath;