Browse Source

Removes unused versionPath

main
Eric Amodio 2 years ago
parent
commit
3a93cc4339
2 changed files with 12 additions and 12 deletions
  1. +9
    -9
      src/git/gitUri.ts
  2. +3
    -3
      src/trackers/documentTracker.ts

+ 9
- 9
src/git/gitUri.ts View File

@ -13,7 +13,6 @@ export interface GitCommitish {
fileName?: string; fileName?: string;
repoPath: string; repoPath: string;
sha?: string; sha?: string;
versionedPath?: string;
} }
interface UriComponents { interface UriComponents {
@ -43,7 +42,6 @@ export class GitUri extends (Uri as any as UriEx) {
readonly repoPath?: string; readonly repoPath?: string;
readonly sha?: string; readonly sha?: string;
readonly versionedPath?: string;
constructor(uri?: Uri); constructor(uri?: Uri);
constructor(uri: Uri, commit: GitCommitish); constructor(uri: Uri, commit: GitCommitish);
@ -140,7 +138,6 @@ export class GitUri extends (Uri as any as UriEx) {
fragment: uri.fragment, fragment: uri.fragment,
}); });
this.repoPath = commitOrRepoPath.repoPath; this.repoPath = commitOrRepoPath.repoPath;
this.versionedPath = commitOrRepoPath.versionedPath;
if (GitRevision.isUncommittedStaged(commitOrRepoPath.sha) || !GitRevision.isUncommitted(commitOrRepoPath.sha)) { if (GitRevision.isUncommittedStaged(commitOrRepoPath.sha) || !GitRevision.isUncommitted(commitOrRepoPath.sha)) {
this.sha = commitOrRepoPath.sha; this.sha = commitOrRepoPath.sha;
} }
@ -181,12 +178,15 @@ export class GitUri extends (Uri as any as UriEx) {
return GitRevision.shorten(this.sha); return GitRevision.shorten(this.sha);
} }
@memoize<GitUri['documentUri']>(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) { equals(uri: Uri | undefined) {

+ 3
- 3
src/trackers/documentTracker.ts View File

@ -286,7 +286,7 @@ export class DocumentTracker implements Disposable {
let document; let document;
if (GitUri.is(documentOrId)) { if (GitUri.is(documentOrId)) {
try { try {
document = await workspace.openTextDocument(documentOrId.documentUri(true));
document = await workspace.openTextDocument(documentOrId.documentUri());
} catch (ex) { } catch (ex) {
const msg: string = ex?.toString() ?? ''; const msg: string = ex?.toString() ?? '';
if (msg.includes('File seems to be binary and cannot be opened as text')) { 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) { private _get(documentOrId: string | TextDocument | Uri) {
if (GitUri.is(documentOrId)) { if (GitUri.is(documentOrId)) {
documentOrId = GitUri.toKey(documentOrId.documentUri(true));
documentOrId = GitUri.toKey(documentOrId.documentUri());
} else if (typeof documentOrId === 'string' || documentOrId instanceof Uri) { } else if (typeof documentOrId === 'string' || documentOrId instanceof Uri) {
documentOrId = GitUri.toKey(documentOrId); documentOrId = GitUri.toKey(documentOrId);
} }
@ -426,7 +426,7 @@ class EmptyTextDocument implements TextDocument {
readonly version: number; readonly version: number;
constructor(public readonly gitUri: GitUri) { constructor(public readonly gitUri: GitUri) {
this.uri = gitUri.documentUri(true);
this.uri = gitUri.documentUri();
this.eol = EndOfLine.LF; this.eol = EndOfLine.LF;
this.fileName = this.uri.fsPath; this.fileName = this.uri.fsPath;

Loading…
Cancel
Save