Commit 3f079d84 authored by Denys Mishunov's avatar Denys Mishunov

Logically split onInstanceDisposal into two fns

As per review
parent 7e78bc41
......@@ -151,9 +151,12 @@ export default class EditorLite {
return decoratedInstance;
};
static onInstanceDisposal(editor, instance, model) {
static removeInstanceFromRegistry(editor, instance) {
const index = editor.instances.findIndex((inst) => inst === instance);
editor.instances.splice(index, 1);
}
static disposeInstanceModels(editor, instance, model) {
const instanceModel = instance.getModel() || model;
if (!instanceModel) {
return;
......@@ -192,7 +195,6 @@ export default class EditorLite {
} = {}) {
EditorLite.prepareInstance(el);
let model;
const createEditorFn = diff ? 'createDiffEditor' : 'create';
const instance = EditorLite.convertMonacoToELInstance(
monacoEditor[createEditorFn].call(this, el, {
......@@ -201,6 +203,7 @@ export default class EditorLite {
}),
);
let model;
if (instanceOptions.model !== null) {
model = EditorLite.createEditorModel({
blobGlobalId,
......@@ -213,7 +216,8 @@ export default class EditorLite {
}
instance.onDidDispose(() => {
EditorLite.onInstanceDisposal(this, instance, model);
EditorLite.removeInstanceFromRegistry(this, instance);
EditorLite.disposeInstanceModels(this, instance, model);
});
EditorLite.manageDefaultExtensions(instance, el, extensions);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment