diff --git a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts index c0ef8a3df46..738ff3a1c87 100644 --- a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts +++ b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts @@ -254,7 +254,9 @@ export class RemoteFileService extends FileService { } }; - return toDecodeStream(createReadableOfProvider(provider, resource), decodeStreamOpts).then(data => { + const readable = createReadableOfProvider(provider, resource, options.position || 0); + + return toDecodeStream(readable, decodeStreamOpts).then(data => { if (options.acceptTextOnly && data.detected.seemsBinary) { return TPromise.wrapError(new FileOperationError( diff --git a/src/vs/workbench/services/files/electron-browser/streams.ts b/src/vs/workbench/services/files/electron-browser/streams.ts index e9feb593c21..08bf5ca41e1 100644 --- a/src/vs/workbench/services/files/electron-browser/streams.ts +++ b/src/vs/workbench/services/files/electron-browser/streams.ts @@ -66,17 +66,17 @@ function createWritable(provider: IReadWriteProvider, resource: URI): Writable { }; } -export function createReadableOfProvider(provider: IFileSystemProvider, resource: URI): Readable { +export function createReadableOfProvider(provider: IFileSystemProvider, resource: URI, position: number): Readable { switch (provider._type) { - case 'simple': return createSimpleReadable(provider, resource); - case 'chunked': return createReadable(provider, resource); + case 'simple': return createSimpleReadable(provider, resource, position); + case 'chunked': return createReadable(provider, resource, position); } } -function createReadable(provider: IReadWriteProvider, resource: URI): Readable { +function createReadable(provider: IReadWriteProvider, resource: URI, position: number): Readable { return new class extends Readable { _fd: number; - _pos: number = 0; + _pos: number = position; _reading: boolean = false; constructor(opts?) { super(opts); @@ -117,7 +117,7 @@ function createReadable(provider: IReadWriteProvider, resource: URI): Readable { }; } -function createSimpleReadable(provider: ISimpleReadWriteProvider, resource: URI): Readable { +function createSimpleReadable(provider: ISimpleReadWriteProvider, resource: URI, position: number): Readable { return new class extends Readable { _readOperation: Thenable; _read(size?: number): void { @@ -125,7 +125,7 @@ function createSimpleReadable(provider: ISimpleReadWriteProvider, resource: URI) return; } this._readOperation = provider.readFile(resource).then(data => { - this.push(data); + this.push(data.slice(position)); this.push(null); }, err => { this.emit('error', err);