Make resolveExternalUri return just a plain uri instead of a disposable result

For #81131

We had trouble coming up with cases where extensions could actually reliably dispose of the resolved uri
This commit is contained in:
Matt Bierner
2019-09-23 10:40:58 -07:00
parent 00983bcdf0
commit a62b7dabe7
5 changed files with 15 additions and 39 deletions

View File

@@ -9,7 +9,6 @@ import { WindowState } from 'vscode';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { once } from 'vs/base/common/functional';
export class ExtHostWindow implements ExtHostWindowShape {
@@ -55,19 +54,14 @@ export class ExtHostWindow implements ExtHostWindowShape {
return this._proxy.$openUri(stringOrUri, options);
}
async resolveExternalUri(uri: URI, options: IOpenUriOptions): Promise<{ resolved: URI, dispose(): void }> {
async resolveExternalUri(uri: URI, options: IOpenUriOptions): Promise<URI> {
if (isFalsyOrWhitespace(uri.scheme)) {
return Promise.reject('Invalid scheme - cannot be empty');
} else if (!new Set([Schemas.http, Schemas.https]).has(uri.scheme)) {
return Promise.reject(`Invalid scheme '${uri.scheme}'`);
}
const { result, handle } = await this._proxy.$resolveExternalUri(uri, options);
return {
resolved: URI.from(result),
dispose: once(() => {
this._proxy.$releaseResolvedExternalUri(handle);
}),
};
const result = await this._proxy.$resolveExternalUri(uri, options);
return URI.from(result);
}
}