mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
files2 - always trigger activation event for fs provider, even if already registered
This commit is contained in:
parent
c0432ebae5
commit
466e69b8ed
|
@ -69,12 +69,10 @@ export class FileService2 extends Disposable implements IFileService {
|
|||
}
|
||||
|
||||
activateProvider(scheme: string): Promise<void> {
|
||||
if (this.provider.has(scheme)) {
|
||||
return Promise.resolve(); // provider is already here! TODO@ben should we still activate by event but not wait for it?
|
||||
}
|
||||
|
||||
// Emit an event that we are about to activate a provider with the given scheme.
|
||||
// Listeners can participate in the activation by registering a provider for it.
|
||||
const joiners: Promise<void>[] = [];
|
||||
|
||||
this._onWillActivateFileSystemProvider.fire({
|
||||
scheme,
|
||||
join(promise) {
|
||||
|
@ -84,6 +82,12 @@ export class FileService2 extends Disposable implements IFileService {
|
|||
},
|
||||
});
|
||||
|
||||
if (this.provider.has(scheme)) {
|
||||
return Promise.resolve(); // provider is already here so we can return directly
|
||||
}
|
||||
|
||||
// If the provider is not yet there, make sure to join on the listeners assuming
|
||||
// that it takes a bit longer to register the file system provider.
|
||||
return Promise.all(joiners).then(() => undefined);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,11 @@ suite('File Service 2', () => {
|
|||
});
|
||||
|
||||
let registrationDisposable: IDisposable;
|
||||
let callCount = 0;
|
||||
service.onWillActivateFileSystemProvider(e => {
|
||||
if (e.scheme === 'test') {
|
||||
callCount++;
|
||||
|
||||
if (e.scheme === 'test' && callCount === 1) {
|
||||
e.join(new Promise(resolve => {
|
||||
registrationDisposable = service.registerProvider('test', new NullFileSystemProvider());
|
||||
|
||||
|
@ -40,6 +43,10 @@ suite('File Service 2', () => {
|
|||
assert.equal(registrations.length, 1);
|
||||
assert.equal(registrations[0].scheme, 'test');
|
||||
assert.equal(registrations[0].added, true);
|
||||
assert.ok(registrationDisposable);
|
||||
|
||||
await service.activateProvider('test');
|
||||
assert.equal(callCount, 2); // activation is called again
|
||||
|
||||
registrationDisposable.dispose();
|
||||
|
||||
|
|
Loading…
Reference in a new issue