scheme and path or authoriy are mandated, fixes #2341
This commit is contained in:
parent
9ce2dd1355
commit
8755e438f5
|
@ -75,6 +75,32 @@ suite('workspace-namespace', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, uri scheme/auth/path', function() {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('sc', {
|
||||
provideTextDocumentContent() {
|
||||
return 'SC';
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
workspace.openTextDocument(Uri.parse('sc://auth')).then(doc => {
|
||||
assert.equal(doc.uri.authority, 'auth');
|
||||
assert.equal(doc.uri.path, '');
|
||||
}),
|
||||
workspace.openTextDocument(Uri.parse('sc:///path')).then(doc => {
|
||||
assert.equal(doc.uri.authority, '');
|
||||
assert.equal(doc.uri.path, '/path');
|
||||
}),
|
||||
workspace.openTextDocument(Uri.parse('sc://auth/path')).then(doc => {
|
||||
assert.equal(doc.uri.authority, 'auth');
|
||||
assert.equal(doc.uri.path, '/path');
|
||||
})
|
||||
]).then(() => {
|
||||
registration.dispose();
|
||||
});
|
||||
})
|
||||
|
||||
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
|
||||
return createRandomFile().then(file => {
|
||||
let disposables = [];
|
||||
|
|
|
@ -581,8 +581,8 @@ export class MainThreadDocuments {
|
|||
|
||||
_tryOpenDocument(uri: URI): TPromise<any> {
|
||||
|
||||
if (!uri.scheme || !uri.fsPath) {
|
||||
return TPromise.wrapError('Uri must have scheme and path. One or both are missing in: ' + uri.toString());
|
||||
if (!uri.scheme || !(uri.fsPath || uri.authority)) {
|
||||
return TPromise.wrapError(`Invalid uri. Scheme and authority or path must be set.`);
|
||||
}
|
||||
|
||||
let promise: TPromise<boolean>;
|
||||
|
|
Loading…
Reference in a new issue