diff --git a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts index acc5872827c927a68eb56910792bd8b84d2c1809..52d0da373826216a7cbaf0c19b7f9aac2ee772dc 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts @@ -53,8 +53,8 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape { this._provider.get(handle).$onFileSystemChange(changes); } - $reportFileChunk(handle: number, data: UriComponents, chunk: number[]): void { - this._provider.get(handle).reportFileChunk(URI.revive(data), chunk); + $reportFileChunk(handle: number, session: number, chunk: number[]): void { + this._provider.get(handle).reportFileChunk(session, chunk); } // --- search @@ -64,10 +64,22 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape { } } +class FileReadOperation { + + private static _idPool = 0; + + constructor( + readonly progress: IProgress, + readonly id: number = ++FileReadOperation._idPool + ) { + // + } +} + class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProvider { private readonly _onDidChange = new Emitter(); - private readonly _reads = new Map>(); + private readonly _reads = new Map(); private readonly _registrations: IDisposable[]; readonly onDidChange: Event = this._onDidChange.event; @@ -104,11 +116,12 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv return this._proxy.$stat(this._handle, resource); } read(resource: URI, offset: number, count: number, progress: IProgress): TPromise { - this._reads.set(resource.toString(), progress); - return this._proxy.$read(this._handle, offset, count, resource); + const read = new FileReadOperation(progress); + this._reads.set(read.id, read); + return this._proxy.$read(this._handle, read.id, offset, count, resource); } - reportFileChunk(resource: URI, chunk: number[]): void { - this._reads.get(resource.toString()).report(Buffer.from(chunk)); + reportFileChunk(session: number, chunk: number[]): void { + this._reads.get(session).progress.report(Buffer.from(chunk)); } write(resource: URI, content: Uint8Array): TPromise { return this._proxy.$write(this._handle, resource, [].slice.call(content)); @@ -143,7 +156,7 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv const id = ++this._searchesIdPool; const matches: IFileMatch[] = []; return new PPromise((resolve, reject, report) => { - this._proxy.$fileFiles(this._handle, id, query.filePattern).then(() => { + this._proxy.$findFiles(this._handle, id, query.filePattern).then(() => { this._searches.delete(id); resolve({ results: matches, diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 9ec2422972fa314e1c348679a8b9175ed401d580..d189f463f6bdb2b30272d1b0ca1768a6b155fa68 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -371,7 +371,7 @@ export interface MainThreadFileSystemShape extends IDisposable { $onDidAddFileSystemRoot(root: UriComponents): void; $onFileSystemChange(handle: number, resource: IFileChange[]): void; - $reportFileChunk(handle: number, resource: UriComponents, chunk: number[] | null): void; + $reportFileChunk(handle: number, session: number, chunk: number[] | null): void; $handleSearchProgress(handle: number, session: number, resource: UriComponents): void; } @@ -535,14 +535,14 @@ export interface ExtHostWorkspaceShape { export interface ExtHostFileSystemShape { $utimes(handle: number, resource: UriComponents, mtime: number, atime: number): TPromise; $stat(handle: number, resource: UriComponents): TPromise; - $read(handle: number, offset: number, count: number, resource: UriComponents): TPromise; + $read(handle: number, session: number, offset: number, count: number, resource: UriComponents): TPromise; $write(handle: number, resource: UriComponents, content: number[]): TPromise; $unlink(handle: number, resource: UriComponents): TPromise; $move(handle: number, resource: UriComponents, target: UriComponents): TPromise; $mkdir(handle: number, resource: UriComponents): TPromise; $readdir(handle: number, resource: UriComponents): TPromise<[UriComponents, IStat][]>; $rmdir(handle: number, resource: UriComponents): TPromise; - $fileFiles(handle: number, session: number, query: string): TPromise; + $findFiles(handle: number, session: number, query: string): TPromise; } export interface ExtHostExtensionServiceShape { diff --git a/src/vs/workbench/api/node/extHostFileSystem.ts b/src/vs/workbench/api/node/extHostFileSystem.ts index 3cdd834d7a712e7c19b7d958cedd9d841612da7f..c2ad87af99017134d1a4f8d4c6bdb41d6e78508e 100644 --- a/src/vs/workbench/api/node/extHostFileSystem.ts +++ b/src/vs/workbench/api/node/extHostFileSystem.ts @@ -48,10 +48,10 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { $stat(handle: number, resource: UriComponents): TPromise { return asWinJsPromise(token => this._provider.get(handle).stat(URI.revive(resource))); } - $read(handle: number, offset: number, count: number, resource: UriComponents): TPromise { + $read(handle: number, session: number, offset: number, count: number, resource: UriComponents): TPromise { const progress = { report: chunk => { - this._proxy.$reportFileChunk(handle, resource, [].slice.call(chunk)); + this._proxy.$reportFileChunk(handle, session, [].slice.call(chunk)); } }; return asWinJsPromise(token => this._provider.get(handle).read(URI.revive(resource), offset, count, progress)); @@ -74,7 +74,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { $rmdir(handle: number, resource: UriComponents): TPromise { return asWinJsPromise(token => this._provider.get(handle).rmdir(URI.revive(resource))); } - $fileFiles(handle: number, session: number, query: string): TPromise { + $findFiles(handle: number, session: number, query: string): TPromise { const provider = this._provider.get(handle); if (!provider.findFiles) { return TPromise.as(undefined);