mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
proposed API and its wiring
This commit is contained in:
@@ -18,6 +18,8 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { RemoteFileService, IRemoteFileSystemProvider } from 'vs/workbench/services/files/electron-browser/remoteFileService';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
|
||||
export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
@@ -108,4 +110,32 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
return bulkEdit(this._textModelResolverService, codeEditor, edits, this._fileService)
|
||||
.then(() => true);
|
||||
}
|
||||
|
||||
// --- EXPERIMENT: workspace provider
|
||||
|
||||
private _provider = new Map<number, [IRemoteFileSystemProvider, Emitter<URI>]>();
|
||||
|
||||
$registerFileSystemProvider(handle: number, authority: string): void {
|
||||
if (!(this._fileService instanceof RemoteFileService)) {
|
||||
throw new Error();
|
||||
}
|
||||
const emitter = new Emitter<URI>();
|
||||
const provider = {
|
||||
onDidChange: emitter.event,
|
||||
resolve: (resource) => {
|
||||
return this._proxy.$resolveFile(handle, resource);
|
||||
},
|
||||
update: (resource, value) => {
|
||||
return this._proxy.$storeFile(handle, resource, value);
|
||||
}
|
||||
};
|
||||
this._provider.set(handle, [provider, emitter]);
|
||||
this._fileService.registerProvider(authority, provider);
|
||||
}
|
||||
|
||||
$onFileSystemChange(handle: number, resource: URI) {
|
||||
const [, emitter] = this._provider.get(handle);
|
||||
emitter.fire(resource);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user