Merge pull request #2087 from ajaxorg/destroy
destroy session when destroying the editor
This commit is contained in:
commit
549df3c756
6 changed files with 40 additions and 26 deletions
|
|
@ -268,7 +268,7 @@ var EditSession = function(text, mode) {
|
||||||
this.$informUndoManager.schedule();
|
this.$informUndoManager.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bgTokenizer.$updateOnChange(delta);
|
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
|
||||||
this._signal("change", e);
|
this._signal("change", e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -276,8 +276,6 @@ var EditSession = function(text, mode) {
|
||||||
* Sets the session text.
|
* Sets the session text.
|
||||||
* @param {String} text The new text to place
|
* @param {String} text The new text to place
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
this.setValue = function(text) {
|
this.setValue = function(text) {
|
||||||
this.doc.setValue(text);
|
this.doc.setValue(text);
|
||||||
|
|
@ -960,12 +958,11 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.$stopWorker = function() {
|
this.$stopWorker = function() {
|
||||||
if (this.$worker)
|
if (this.$worker) {
|
||||||
this.$worker.terminate();
|
this.$worker.terminate();
|
||||||
|
|
||||||
this.$worker = null;
|
this.$worker = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$startWorker = function() {
|
this.$startWorker = function() {
|
||||||
|
|
@ -2404,7 +2401,15 @@ var EditSession = function(text, mode) {
|
||||||
*/
|
*/
|
||||||
this.$setFontMetrics = function(fm) {
|
this.$setFontMetrics = function(fm) {
|
||||||
// todo
|
// todo
|
||||||
|
};
|
||||||
|
|
||||||
|
this.destroy = function() {
|
||||||
|
if (this.bgTokenizer) {
|
||||||
|
this.bgTokenizer.setDocument(null);
|
||||||
|
this.bgTokenizer = null;
|
||||||
}
|
}
|
||||||
|
this.$stopWorker();
|
||||||
|
};
|
||||||
|
|
||||||
// For every keystroke this gets called once per char in the whole doc!!
|
// For every keystroke this gets called once per char in the whole doc!!
|
||||||
// Wouldn't hurt to make it a bit faster for c >= 0x1100
|
// Wouldn't hurt to make it a bit faster for c >= 0x1100
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ var Editor = function(renderer, session) {
|
||||||
|
|
||||||
this._$emitInputEvent = lang.delayedCall(function() {
|
this._$emitInputEvent = lang.delayedCall(function() {
|
||||||
this._signal("input", {});
|
this._signal("input", {});
|
||||||
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
|
if (this.session && this.session.bgTokenizer)
|
||||||
|
this.session.bgTokenizer.scheduleStart();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.on("change", function(_, _self) {
|
this.on("change", function(_, _self) {
|
||||||
|
|
@ -380,6 +381,9 @@ var Editor = function(renderer, session) {
|
||||||
this.onChangeAnnotation();
|
this.onChangeAnnotation();
|
||||||
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
||||||
this.renderer.updateFull();
|
this.renderer.updateFull();
|
||||||
|
} else {
|
||||||
|
this.selection = null;
|
||||||
|
this.renderer.setSession(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._signal("changeSession", {
|
this._signal("changeSession", {
|
||||||
|
|
@ -2517,6 +2521,9 @@ var Editor = function(renderer, session) {
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
this.renderer.destroy();
|
this.renderer.destroy();
|
||||||
this._signal("destroy", this);
|
this._signal("destroy", this);
|
||||||
|
if (this.session) {
|
||||||
|
this.session.destroy();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ var Gutter = function(parentEl) {
|
||||||
if (this.session)
|
if (this.session)
|
||||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
if (session)
|
||||||
session.on("change", this.$updateAnnotations);
|
session.on("change", this.$updateAnnotations);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ var Text = function(parentEl) {
|
||||||
};
|
};
|
||||||
this.setSession = function(session) {
|
this.setSession = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
if (session)
|
||||||
this.$computeTabString();
|
this.$computeTabString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -858,12 +858,12 @@ function isSamePoint(p1, p2) {
|
||||||
// adds multicursor support to a session
|
// adds multicursor support to a session
|
||||||
exports.onSessionChange = function(e) {
|
exports.onSessionChange = function(e) {
|
||||||
var session = e.session;
|
var session = e.session;
|
||||||
if (!session.multiSelect) {
|
if (session && !session.multiSelect) {
|
||||||
session.$selectionMarkers = [];
|
session.$selectionMarkers = [];
|
||||||
session.selection.$initRangeList();
|
session.selection.$initRangeList();
|
||||||
session.multiSelect = session.selection;
|
session.multiSelect = session.selection;
|
||||||
}
|
}
|
||||||
this.multiSelect = session.multiSelect;
|
this.multiSelect = session && session.multiSelect;
|
||||||
|
|
||||||
var oldSession = e.oldSession;
|
var oldSession = e.oldSession;
|
||||||
if (oldSession) {
|
if (oldSession) {
|
||||||
|
|
@ -875,16 +875,16 @@ exports.onSessionChange = function(e) {
|
||||||
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
|
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (session) {
|
||||||
session.multiSelect.on("addRange", this.$onAddRange);
|
session.multiSelect.on("addRange", this.$onAddRange);
|
||||||
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
||||||
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
||||||
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
||||||
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
||||||
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
||||||
|
}
|
||||||
|
|
||||||
// this.$onSelectionChange = this.onSelectionChange.bind(this);
|
if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
||||||
|
|
||||||
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
|
||||||
if (session.selection.inMultiSelectMode)
|
if (session.selection.inMultiSelectMode)
|
||||||
this.$onMultiSelect();
|
this.$onMultiSelect();
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -232,10 +232,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
|
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
|
||||||
|
|
||||||
this.session = session;
|
this.session = session;
|
||||||
if (!session)
|
if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
|
||||||
return;
|
|
||||||
|
|
||||||
if (this.scrollMargin.top && session.getScrollTop() <= 0)
|
|
||||||
session.setScrollTop(-this.scrollMargin.top);
|
session.setScrollTop(-this.scrollMargin.top);
|
||||||
|
|
||||||
this.$cursorLayer.setSession(session);
|
this.$cursorLayer.setSession(session);
|
||||||
|
|
@ -243,6 +240,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$markerFront.setSession(session);
|
this.$markerFront.setSession(session);
|
||||||
this.$gutterLayer.setSession(session);
|
this.$gutterLayer.setSession(session);
|
||||||
this.$textLayer.setSession(session);
|
this.$textLayer.setSession(session);
|
||||||
|
if (!session)
|
||||||
|
return;
|
||||||
|
|
||||||
this.$loop.schedule(this.CHANGE_FULL);
|
this.$loop.schedule(this.CHANGE_FULL);
|
||||||
this.session.$setFontMetrics(this.$fontMetrics);
|
this.session.$setFontMetrics(this.$fontMetrics);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue