From 2d9528ab55e083ee590ddb61fb85cbf932117cf0 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 20 Apr 2018 12:34:12 +0200 Subject: [PATCH] only allow events from a provider's scheme, #47475 --- src/vs/workbench/api/node/extHostFileSystem.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/api/node/extHostFileSystem.ts b/src/vs/workbench/api/node/extHostFileSystem.ts index ae0e2689e4e..417d3f3e8a1 100644 --- a/src/vs/workbench/api/node/extHostFileSystem.ts +++ b/src/vs/workbench/api/node/extHostFileSystem.ts @@ -7,7 +7,7 @@ import URI, { UriComponents } from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { Event, mapEvent } from 'vs/base/common/event'; -import { MainContext, IMainContext, ExtHostFileSystemShape, MainThreadFileSystemShape } from './extHost.protocol'; +import { MainContext, IMainContext, ExtHostFileSystemShape, MainThreadFileSystemShape, IFileChangeDto } from './extHost.protocol'; import * as vscode from 'vscode'; import * as files from 'vs/platform/files/common/files'; import * as path from 'path'; @@ -220,8 +220,13 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { this._proxy.$registerFileSystemProvider(handle, scheme, capabilites); const subscription = provider.onDidChangeFile(event => { - let newEvent = event.map(e => { + let mapped: IFileChangeDto[] = []; + for (const e of event) { let { uri: resource, type } = e; + if (resource.scheme !== scheme) { + // dropping events for wrong scheme + continue; + } let newType: files.FileChangeType; switch (type) { case FileChangeType2.Changed: @@ -234,9 +239,9 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { newType = files.FileChangeType.DELETED; break; } - return { resource, type: newType }; - }); - this._proxy.$onFileSystemChange(handle, newEvent); + mapped.push({ resource, type: newType }); + } + this._proxy.$onFileSystemChange(handle, mapped); }); return {