diff --git a/src/vs/platform/extensionManagement/node/extensionsWatcher.ts b/src/vs/platform/extensionManagement/node/extensionsWatcher.ts index 9f2ca6fd922..abff043fd31 100644 --- a/src/vs/platform/extensionManagement/node/extensionsWatcher.ts +++ b/src/vs/platform/extensionManagement/node/extensionsWatcher.ts @@ -41,7 +41,7 @@ export class ExtensionsWatcher extends Disposable { const extensionsResource = URI.file(environmentService.extensionsPath); const extUri = new ExtUri(resource => !fileService.hasCapability(resource, FileSystemProviderCapabilities.PathCaseSensitive)); this._register(fileService.watch(extensionsResource)); - this._register(Event.filter(fileService.onDidChangeFilesRaw, raw => raw.some(change => this.doesChangeAffects(change, extensionsResource, extUri)))(() => this.onDidChange())); + this._register(Event.filter(fileService.onDidChangeFilesRaw, e => e.changes.some(change => this.doesChangeAffects(change, extensionsResource, extUri)))(() => this.onDidChange())); } private doesChangeAffects(change: IFileChange, extensionsResource: URI, extUri: ExtUri): boolean { diff --git a/src/vs/platform/files/common/fileService.ts b/src/vs/platform/files/common/fileService.ts index cebcb7ec74a..d6fc1dc63cd 100644 --- a/src/vs/platform/files/common/fileService.ts +++ b/src/vs/platform/files/common/fileService.ts @@ -6,7 +6,7 @@ import { localize } from 'vs/nls'; import { mark } from 'vs/base/common/performance'; import { Disposable, IDisposable, toDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle'; -import { IFileService, IResolveFileOptions, FileChangesEvent, FileOperationEvent, IFileSystemProviderRegistrationEvent, IFileSystemProvider, IFileStat, IResolveFileResult, ICreateFileOptions, IFileSystemProviderActivationEvent, FileOperationError, FileOperationResult, FileOperation, FileSystemProviderCapabilities, FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, IStat, IFileStatWithMetadata, IResolveMetadataFileOptions, etag, hasReadWriteCapability, hasFileFolderCopyCapability, hasOpenReadWriteCloseCapability, toFileOperationResult, IFileSystemProviderWithOpenReadWriteCloseCapability, IFileSystemProviderWithFileReadWriteCapability, IResolveFileResultWithMetadata, IWatchOptions, IWriteFileOptions, IReadFileOptions, IFileStreamContent, IFileContent, ETAG_DISABLED, hasFileReadStreamCapability, IFileSystemProviderWithFileReadStreamCapability, ensureFileSystemProviderError, IFileSystemProviderCapabilitiesChangeEvent, IReadFileStreamOptions, FileDeleteOptions, FilePermission, NotModifiedSinceFileOperationError, IFileChange } from 'vs/platform/files/common/files'; +import { IFileService, IResolveFileOptions, FileChangesEvent, FileOperationEvent, IFileSystemProviderRegistrationEvent, IFileSystemProvider, IFileStat, IResolveFileResult, ICreateFileOptions, IFileSystemProviderActivationEvent, FileOperationError, FileOperationResult, FileOperation, FileSystemProviderCapabilities, FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, IStat, IFileStatWithMetadata, IResolveMetadataFileOptions, etag, hasReadWriteCapability, hasFileFolderCopyCapability, hasOpenReadWriteCloseCapability, toFileOperationResult, IFileSystemProviderWithOpenReadWriteCloseCapability, IFileSystemProviderWithFileReadWriteCapability, IResolveFileResultWithMetadata, IWatchOptions, IWriteFileOptions, IReadFileOptions, IFileStreamContent, IFileContent, ETAG_DISABLED, hasFileReadStreamCapability, IFileSystemProviderWithFileReadStreamCapability, ensureFileSystemProviderError, IFileSystemProviderCapabilitiesChangeEvent, IReadFileStreamOptions, FileDeleteOptions, FilePermission, NotModifiedSinceFileOperationError, IFileChange, IRawFileChangesEvent } from 'vs/platform/files/common/files'; import { URI } from 'vs/base/common/uri'; import { Emitter } from 'vs/base/common/event'; import { IExtUri, extUri, extUriIgnorePathCase, isAbsolutePath } from 'vs/base/common/resources'; @@ -982,7 +982,7 @@ export class FileService extends Disposable implements IFileService { private readonly _onDidFilesChange = this._register(new Emitter()); readonly onDidFilesChange = this._onDidFilesChange.event; - private readonly _onDidChangeFilesRaw = this._register(new Emitter()); + private readonly _onDidChangeFilesRaw = this._register(new Emitter()); readonly onDidChangeFilesRaw = this._onDidChangeFilesRaw.event; private readonly activeWatchers = new Map(); @@ -1009,7 +1009,7 @@ export class FileService extends Disposable implements IFileService { // Event #1: access to raw events goes out instantly { - this._onDidChangeFilesRaw.fire(changes); + this._onDidChangeFilesRaw.fire({ changes }); } // Event #2: immediately send out events for diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index bad6dd986c0..bc31bb9e260 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -84,7 +84,7 @@ export interface IFileService { * @deprecated use this method only if you know what you are doing. use the other watch related events * and APIs for more efficient file watching. */ - readonly onDidChangeFilesRaw: Event; + readonly onDidChangeFilesRaw: Event; /** * An event that is fired upon successful completion of a certain file operation. @@ -648,6 +648,14 @@ export interface IFileChange { readonly resource: URI; } +export interface IRawFileChangesEvent { + + /** + * @deprecated use `FileChangesEvent` instead unless you know what you are doing + */ + readonly changes: readonly IFileChange[]; +} + export class FileChangesEvent { private readonly added: TernarySearchTree | undefined = undefined; diff --git a/src/vs/platform/files/test/electron-browser/diskFileService.test.ts b/src/vs/platform/files/test/electron-browser/diskFileService.test.ts index 54ba93f78db..5f463043228 100644 --- a/src/vs/platform/files/test/electron-browser/diskFileService.test.ts +++ b/src/vs/platform/files/test/electron-browser/diskFileService.test.ts @@ -2283,19 +2283,19 @@ flakySuite('Disk File Service', function () { return raw.map(change => `Change: type ${toString(change.type)} path ${change.resource.toString()}`).join('\n'); } - const listenerDisposable = service.onDidChangeFilesRaw(raw => { + const listenerDisposable = service.onDidChangeFilesRaw(({ changes }) => { watcherDisposable.dispose(); listenerDisposable.dispose(); try { - assert.strictEqual(raw.length, expected.length, `Expected ${expected.length} events, but got ${raw.length}. Details (${printEvents(raw)})`); + assert.strictEqual(changes.length, expected.length, `Expected ${expected.length} events, but got ${changes.length}. Details (${printEvents(changes)})`); if (expected.length === 1) { - assert.strictEqual(raw[0].type, expected[0][0], `Expected ${toString(expected[0][0])} but got ${toString(raw[0].type)}. Details (${printEvents(raw)})`); - assert.strictEqual(raw[0].resource.fsPath, expected[0][1].fsPath); + assert.strictEqual(changes[0].type, expected[0][0], `Expected ${toString(expected[0][0])} but got ${toString(changes[0].type)}. Details (${printEvents(changes)})`); + assert.strictEqual(changes[0].resource.fsPath, expected[0][1].fsPath); } else { for (const expect of expected) { - assert.strictEqual(hasChange(raw, expect[0], expect[1]), true, `Unable to find ${toString(expect[0])} for ${expect[1].fsPath}. Details (${printEvents(raw)})`); + assert.strictEqual(hasChange(changes, expect[0], expect[1]), true, `Unable to find ${toString(expect[0])} for ${expect[1].fsPath}. Details (${printEvents(changes)})`); } } diff --git a/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts b/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts index f9c8758c1be..204033b2759 100644 --- a/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts +++ b/src/vs/workbench/api/browser/mainThreadFileSystemEventService.ts @@ -51,8 +51,8 @@ export class MainThreadFileSystemEventService { changed: [], deleted: [] }; - this._listener.add(fileService.onDidChangeFilesRaw(changes => { - for (let change of changes) { + this._listener.add(fileService.onDidChangeFilesRaw(event => { + for (let change of event.changes) { switch (change.type) { case FileChangeType.ADDED: events.created.push(change.resource); diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index ba6bca07da4..fe9bbae7a91 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -23,7 +23,7 @@ import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbe import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { ILifecycleService, BeforeShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase, WillShutdownEvent } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability, FileReadStreamOptions, IReadFileStreamOptions, IFileSystemProviderCapabilitiesChangeEvent } from 'vs/platform/files/common/files'; +import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability, FileReadStreamOptions, IReadFileStreamOptions, IFileSystemProviderCapabilitiesChangeEvent, IRawFileChangesEvent } from 'vs/platform/files/common/files'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; @@ -836,8 +836,8 @@ export class TestFileService implements IFileService { get onDidFilesChange(): Event { return this._onDidFilesChange.event; } fireFileChanges(event: FileChangesEvent): void { this._onDidFilesChange.fire(event); } - private readonly _onDidChangeFilesRaw = new Emitter(); - get onDidChangeFilesRaw(): Event { return this._onDidChangeFilesRaw.event; } + private readonly _onDidChangeFilesRaw = new Emitter(); + get onDidChangeFilesRaw(): Event { return this._onDidChangeFilesRaw.event; } private readonly _onDidRunOperation = new Emitter(); get onDidRunOperation(): Event { return this._onDidRunOperation.event; }