🐛 isolate git uri handling

fixes #23297
This commit is contained in:
Joao Moreno
2017-04-10 15:28:13 +02:00
parent 0a7bd0a19e
commit 564b9a8a1e
4 changed files with 42 additions and 30 deletions

View File

@@ -7,6 +7,7 @@
import { workspace, Uri, Disposable, Event, EventEmitter, window } from 'vscode';
import { debounce, throttle } from './decorators';
import { fromGitUri } from './uri';
import { Model } from './model';
interface CacheRow {
@@ -32,8 +33,7 @@ export class GitContentProvider {
constructor(private model: Model) {
this.disposables.push(
model.onDidChangeRepository(this.eventuallyFireChangeEvents, this),
workspace.registerTextDocumentContentProvider('git', this),
workspace.registerTextDocumentContentProvider('git-original', this)
workspace.registerTextDocumentContentProvider('git', this)
);
setInterval(() => this.cleanup(), FIVE_MINUTES);
@@ -59,25 +59,17 @@ export class GitContentProvider {
this.cache[cacheKey] = cacheValue;
if (uri.scheme === 'git-original') {
try {
return await this.model.show('', uri.query);
} catch (err) {
return '';
}
}
let ref = uri.query;
let { path, ref } = fromGitUri(uri);
if (ref === '~') {
const fileUri = uri.with({ scheme: 'file', query: '' });
const fileUri = Uri.file(path);
const uriString = fileUri.toString();
const [indexStatus] = this.model.indexGroup.resources.filter(r => r.original.toString() === uriString);
ref = indexStatus ? '' : 'HEAD';
}
try {
return await this.model.show(ref, uri.fsPath);
return await this.model.show(ref, path);
} catch (err) {
return '';
}