Skip to content

Commit

Permalink
Properly hook up dirty indicator for customEditorInput
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Nov 20, 2019
1 parent 73ec85b commit b1a02d3
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { GroupIdentifier, IEditorInput, IRevertOptions, ISaveOptions, Verbosity
import { ICustomEditorModel, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/browser/webview';
import { IWebviewWorkbenchService, LazilyResolvedWebviewEditorInput } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
import { CustomEditorModel } from '../common/customEditorModel';
import { IEditorModel } from 'vs/platform/editor/common/editor';

export class CustomFileEditorInput extends LazilyResolvedWebviewEditorInput {
Expand Down Expand Up @@ -111,14 +110,6 @@ export class CustomFileEditorInput extends LazilyResolvedWebviewEditorInput {
}
}

public setModel(model: CustomEditorModel) {
if (this._model) {
throw new Error('Model is already set');
}
this._model = model;
this._register(model.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
}

public isReadonly(): boolean {
return false;
}
Expand All @@ -142,6 +133,7 @@ export class CustomFileEditorInput extends LazilyResolvedWebviewEditorInput {

public async resolve(): Promise<IEditorModel> {
this._model = await this.customEditorService.models.loadOrCreate(this.getResource(), this.viewType);
this._register(this._model.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
return await super.resolve();
}
}

0 comments on commit b1a02d3

Please sign in to comment.