From b95adfce0ab918b087352f0c4ed8e8b5ceaf58dc Mon Sep 17 00:00:00 2001 From: Dan Arad Date: Thu, 4 Mar 2021 17:47:48 +0200 Subject: [PATCH] 6636 Signed-off-by: Dan Arad --- packages/core/src/browser/saveable.ts | 6 ++--- .../src/browser/editor-preview-widget.ts | 2 +- .../keymaps/src/browser/keymaps-service.ts | 2 +- .../monaco/src/browser/monaco-editor-model.ts | 10 ++++----- .../monaco/src/browser/monaco-workspace.ts | 2 +- .../browser/navigator-tab-bar-decorator.ts | 6 ++--- .../custom-editors/custom-editors-main.ts | 22 +++++++++---------- .../main/browser/text-editor-model-service.ts | 2 +- .../abstract-resource-preference-provider.ts | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/core/src/browser/saveable.ts b/packages/core/src/browser/saveable.ts index eefa0d8c06fc7..ad4ca17f276f9 100644 --- a/packages/core/src/browser/saveable.ts +++ b/packages/core/src/browser/saveable.ts @@ -24,7 +24,7 @@ import { waitForClosed } from './widgets'; export interface Saveable { readonly dirty: boolean; - readonly onDidDirtyChange: Event; + readonly onDirtyChanged: Event; readonly autoSave: 'on' | 'off'; /** * Saves dirty changes. @@ -62,7 +62,7 @@ export namespace Saveable { } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function is(arg: any): arg is Saveable { - return !!arg && ('dirty' in arg) && ('onDidDirtyChange' in arg); + return !!arg && ('dirty' in arg) && ('onDirtyChanged' in arg); } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function get(arg: any): Saveable | undefined { @@ -102,7 +102,7 @@ export namespace Saveable { return undefined; } setDirty(widget, saveable.dirty); - saveable.onDidDirtyChange(() => setDirty(widget, saveable.dirty)); + saveable.onDirtyChanged(() => setDirty(widget, saveable.dirty)); const closeWidget = widget.close.bind(widget); const closeWithoutSaving: SaveableWidget['closeWithoutSaving'] = async () => { if (saveable.dirty && saveable.revert) { diff --git a/packages/editor-preview/src/browser/editor-preview-widget.ts b/packages/editor-preview/src/browser/editor-preview-widget.ts index a899810f0a605..05f682fd03509 100644 --- a/packages/editor-preview/src/browser/editor-preview-widget.ts +++ b/packages/editor-preview/src/browser/editor-preview-widget.ts @@ -118,7 +118,7 @@ export class EditorPreviewWidget extends BaseWidget implements ApplicationShell. if (Saveable.isSource(w)) { Saveable.apply(this); - const dirtyListener = w.saveable.onDidDirtyChange(() => { + const dirtyListener = w.saveable.onDirtyChanged(() => { dirtyListener.dispose(); this.pinEditorWidget(); }); diff --git a/packages/keymaps/src/browser/keymaps-service.ts b/packages/keymaps/src/browser/keymaps-service.ts index 1e8873732abbd..2ba7d24434675 100644 --- a/packages/keymaps/src/browser/keymaps-service.ts +++ b/packages/keymaps/src/browser/keymaps-service.ts @@ -63,7 +63,7 @@ export class KeymapsService { this.reconcile(); this.model.onDidChangeContent(() => this.reconcile()); - this.model.onDidDirtyChange(() => this.reconcile()); + this.model.onDirtyChanged(() => this.reconcile()); this.model.onDidChangeValid(() => this.reconcile()); this.keybindingRegistry.onKeybindingsChanged(() => this.changeKeymapEmitter.fire(undefined)); } diff --git a/packages/monaco/src/browser/monaco-editor-model.ts b/packages/monaco/src/browser/monaco-editor-model.ts index 42ccbc8517e0f..89a8193048a58 100644 --- a/packages/monaco/src/browser/monaco-editor-model.ts +++ b/packages/monaco/src/browser/monaco-editor-model.ts @@ -92,7 +92,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument { this.toDispose.push(this.onDidChangeContentEmitter); this.toDispose.push(this.onDidSaveModelEmitter); this.toDispose.push(this.onWillSaveModelEmitter); - this.toDispose.push(this.onDidDirtyChangeEmitter); + this.toDispose.push(this.onDirtyChangedEmitter); this.toDispose.push(this.onDidChangeValidEmitter); this.toDispose.push(Disposable.create(() => this.cancelSave())); this.toDispose.push(Disposable.create(() => this.cancelSync())); @@ -203,16 +203,16 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument { if (dirty === false) { this.updateSavedVersionId(); } - this.onDidDirtyChangeEmitter.fire(undefined); + this.onDirtyChangedEmitter.fire(undefined); } private updateSavedVersionId(): void { this.bufferSavedVersionId = this.model.getAlternativeVersionId(); } - protected readonly onDidDirtyChangeEmitter = new Emitter(); - get onDidDirtyChange(): Event { - return this.onDidDirtyChangeEmitter.event; + protected readonly onDirtyChangedEmitter = new Emitter(); + get onDirtyChanged(): Event { + return this.onDirtyChangedEmitter.event; } get uri(): string { diff --git a/packages/monaco/src/browser/monaco-workspace.ts b/packages/monaco/src/browser/monaco-workspace.ts index 81f209d71a8e0..027f10efb7ab4 100644 --- a/packages/monaco/src/browser/monaco-workspace.ts +++ b/packages/monaco/src/browser/monaco-workspace.ts @@ -132,7 +132,7 @@ export class MonacoWorkspace { model.onDidChangeContent(event => this.fireDidChangeContent(event)); model.onDidSaveModel(() => this.fireDidSave(model)); model.onWillSaveModel(event => this.fireWillSave(event)); - model.onDidDirtyChange(() => this.openEditorIfDirty(model)); + model.onDirtyChanged(() => this.openEditorIfDirty(model)); model.onDispose(() => this.fireDidClose(model)); } diff --git a/packages/navigator/src/browser/navigator-tab-bar-decorator.ts b/packages/navigator/src/browser/navigator-tab-bar-decorator.ts index 2eddc08090bfb..384ddfe4eb592 100644 --- a/packages/navigator/src/browser/navigator-tab-bar-decorator.ts +++ b/packages/navigator/src/browser/navigator-tab-bar-decorator.ts @@ -29,7 +29,7 @@ export class NavigatorTabBarDecorator implements TabBarDecorator, FrontendApplic protected readonly emitter = new Emitter(); private readonly toDispose = new DisposableCollection(); - private readonly toDisposeOnDidDirtyChange = new Map(); + private readonly toDisposeOnDirtyChanged = new Map(); onStart(app: FrontendApplication): void { this.applicationShell = app.shell; @@ -40,10 +40,10 @@ export class NavigatorTabBarDecorator implements TabBarDecorator, FrontendApplic this.applicationShell.onDidAddWidget(widget => { const saveable = Saveable.get(widget); if (saveable) { - this.toDisposeOnDidDirtyChange.set(widget.id, saveable.onDidDirtyChange(() => this.fireDidChangeDecorations())); + this.toDisposeOnDirtyChanged.set(widget.id, saveable.onDirtyChanged(() => this.fireDidChangeDecorations())); } }), - this.applicationShell.onDidRemoveWidget(widget => this.toDisposeOnDidDirtyChange.get(widget.id)?.dispose()) + this.applicationShell.onDidRemoveWidget(widget => this.toDisposeOnDirtyChanged.get(widget.id)?.dispose()) ]); } diff --git a/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts b/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts index f090f1d0638a2..2a9ee5d3089a1 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts +++ b/packages/plugin-ext/src/main/browser/custom-editors/custom-editors-main.ts @@ -122,7 +122,7 @@ export class CustomEditorsMainImpl implements CustomEditorsMain, Disposable { widget.onDidDispose(() => { // If the model is still dirty, make sure we have time to save it if (modelRef.object.dirty) { - const sub = modelRef.object.onDidDirtyChange(() => { + const sub = modelRef.object.onDirtyChanged(() => { if (!modelRef.object.dirty) { sub.dispose(); modelRef.dispose(); @@ -247,7 +247,7 @@ export interface CustomEditorModel extends Saveable, Disposable { readonly resource: URI; readonly readonly: boolean; readonly dirty: boolean; - readonly onDidDirtyChange: Event; + readonly onDirtyChanged: Event; revert(options?: Saveable.RevertOptions): Promise; saveCustomEditor(options?: SaveOptions): Promise; @@ -262,8 +262,8 @@ export class MainCustomEditorModel implements CustomEditorModel { private readonly edits: Array = []; private readonly toDispose = new DisposableCollection(); - private readonly onDidDirtyChangeEmitter = new Emitter(); - readonly onDidDirtyChange = this.onDidDirtyChangeEmitter.event; + private readonly onDirtyChangedEmitter = new Emitter(); + readonly onDirtyChanged = this.onDirtyChangedEmitter.event; autoSave: 'on' | 'off'; autoSaveDelay: number; @@ -303,7 +303,7 @@ export class MainCustomEditorModel implements CustomEditorModel { } }) ); - this.toDispose.push(this.onDidDirtyChangeEmitter); + this.toDispose.push(this.onDirtyChangedEmitter); } get resource(): URI { @@ -471,7 +471,7 @@ export class MainCustomEditorModel implements CustomEditorModel { makeEdit(); if (this.dirty !== wasDirty) { - this.onDidDirtyChangeEmitter.fire(); + this.onDirtyChangedEmitter.fire(); } if (this.autoSave === 'on') { @@ -487,8 +487,8 @@ export class MainCustomEditorModel implements CustomEditorModel { // copied from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.ts export class CustomTextEditorModel implements CustomEditorModel { private readonly toDispose = new DisposableCollection(); - private readonly onDidDirtyChangeEmitter = new Emitter(); - readonly onDidDirtyChange = this.onDidDirtyChangeEmitter.event; + private readonly onDirtyChangedEmitter = new Emitter(); + readonly onDirtyChanged = this.onDirtyChangedEmitter.event; readonly autoSave: 'on' | 'off'; static async create( @@ -509,11 +509,11 @@ export class CustomTextEditorModel implements CustomEditorModel { private readonly fileService: FileService ) { this.toDispose.push( - this.editorTextModel.onDidDirtyChange(e => { - this.onDidDirtyChangeEmitter.fire(); + this.editorTextModel.onDirtyChanged(e => { + this.onDirtyChangedEmitter.fire(); }) ); - this.toDispose.push(this.onDidDirtyChangeEmitter); + this.toDispose.push(this.onDirtyChangedEmitter); } dispose(): void { diff --git a/packages/plugin-ext/src/main/browser/text-editor-model-service.ts b/packages/plugin-ext/src/main/browser/text-editor-model-service.ts index 39b003f2a6a32..2a38f48c2c1c1 100644 --- a/packages/plugin-ext/src/main/browser/text-editor-model-service.ts +++ b/packages/plugin-ext/src/main/browser/text-editor-model-service.ts @@ -60,7 +60,7 @@ export class EditorModelService { this.modelSavedEmitter.fire(model); }); - model.onDidDirtyChange(_ => { + model.onDirtyChanged(_ => { this.modelDirtyEmitter.fire(model); }); model.onWillSaveModel(willSaveModelEvent => { diff --git a/packages/preferences/src/browser/abstract-resource-preference-provider.ts b/packages/preferences/src/browser/abstract-resource-preference-provider.ts index 741a794b87d64..976f124514dcd 100644 --- a/packages/preferences/src/browser/abstract-resource-preference-provider.ts +++ b/packages/preferences/src/browser/abstract-resource-preference-provider.ts @@ -70,7 +70,7 @@ export abstract class AbstractResourcePreferenceProvider extends PreferenceProvi this.readPreferences(); this.toDispose.push(this.model.onDidChangeContent(() => this.readPreferences())); - this.toDispose.push(this.model.onDidDirtyChange(() => this.readPreferences())); + this.toDispose.push(this.model.onDirtyChanged(() => this.readPreferences())); this.toDispose.push(this.model.onDidChangeValid(() => this.readPreferences())); this.toDispose.push(Disposable.create(() => this.reset()));