Skip to content

Commit

Permalink
6636
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Arad <dan.arad@sap.com>
  • Loading branch information
danarad05 committed Mar 4, 2021
1 parent 92e11ad commit b95adfc
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/browser/saveable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { waitForClosed } from './widgets';

export interface Saveable {
readonly dirty: boolean;
readonly onDidDirtyChange: Event<void>;
readonly onDirtyChanged: Event<void>;
readonly autoSave: 'on' | 'off';
/**
* Saves dirty changes.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/keymaps/src/browser/keymaps-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
10 changes: 5 additions & 5 deletions packages/monaco/src/browser/monaco-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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<void>();
get onDidDirtyChange(): Event<void> {
return this.onDidDirtyChangeEmitter.event;
protected readonly onDirtyChangedEmitter = new Emitter<void>();
get onDirtyChanged(): Event<void> {
return this.onDirtyChangedEmitter.event;
}

get uri(): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
6 changes: 3 additions & 3 deletions packages/navigator/src/browser/navigator-tab-bar-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class NavigatorTabBarDecorator implements TabBarDecorator, FrontendApplic

protected readonly emitter = new Emitter<void>();
private readonly toDispose = new DisposableCollection();
private readonly toDisposeOnDidDirtyChange = new Map<string, Disposable>();
private readonly toDisposeOnDirtyChanged = new Map<string, Disposable>();

onStart(app: FrontendApplication): void {
this.applicationShell = app.shell;
Expand All @@ -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())
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -247,7 +247,7 @@ export interface CustomEditorModel extends Saveable, Disposable {
readonly resource: URI;
readonly readonly: boolean;
readonly dirty: boolean;
readonly onDidDirtyChange: Event<void>;
readonly onDirtyChanged: Event<void>;

revert(options?: Saveable.RevertOptions): Promise<void>;
saveCustomEditor(options?: SaveOptions): Promise<void>;
Expand All @@ -262,8 +262,8 @@ export class MainCustomEditorModel implements CustomEditorModel {
private readonly edits: Array<number> = [];
private readonly toDispose = new DisposableCollection();

private readonly onDidDirtyChangeEmitter = new Emitter<void>();
readonly onDidDirtyChange = this.onDidDirtyChangeEmitter.event;
private readonly onDirtyChangedEmitter = new Emitter<void>();
readonly onDirtyChanged = this.onDirtyChangedEmitter.event;

autoSave: 'on' | 'off';
autoSaveDelay: number;
Expand Down Expand Up @@ -303,7 +303,7 @@ export class MainCustomEditorModel implements CustomEditorModel {
}
})
);
this.toDispose.push(this.onDidDirtyChangeEmitter);
this.toDispose.push(this.onDirtyChangedEmitter);
}

get resource(): URI {
Expand Down Expand Up @@ -471,7 +471,7 @@ export class MainCustomEditorModel implements CustomEditorModel {
makeEdit();

if (this.dirty !== wasDirty) {
this.onDidDirtyChangeEmitter.fire();
this.onDirtyChangedEmitter.fire();
}

if (this.autoSave === 'on') {
Expand All @@ -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<void>();
readonly onDidDirtyChange = this.onDidDirtyChangeEmitter.event;
private readonly onDirtyChangedEmitter = new Emitter<void>();
readonly onDirtyChanged = this.onDirtyChangedEmitter.event;
readonly autoSave: 'on' | 'off';

static async create(
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class EditorModelService {
this.modelSavedEmitter.fire(model);
});

model.onDidDirtyChange(_ => {
model.onDirtyChanged(_ => {
this.modelDirtyEmitter.fire(model);
});
model.onWillSaveModel(willSaveModelEvent => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit b95adfc

Please sign in to comment.