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.bgTokenizer.$updateOnChange(delta);
|
||||
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
|
||||
this._signal("change", e);
|
||||
};
|
||||
|
||||
|
|
@ -276,8 +276,6 @@ var EditSession = function(text, mode) {
|
|||
* Sets the session text.
|
||||
* @param {String} text The new text to place
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.setValue = function(text) {
|
||||
this.doc.setValue(text);
|
||||
|
|
@ -960,12 +958,11 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
this.$stopWorker = function() {
|
||||
if (this.$worker)
|
||||
if (this.$worker) {
|
||||
this.$worker.terminate();
|
||||
|
||||
this.$worker = null;
|
||||
this.$worker = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.$startWorker = function() {
|
||||
|
|
@ -2404,7 +2401,15 @@ var EditSession = function(text, mode) {
|
|||
*/
|
||||
this.$setFontMetrics = function(fm) {
|
||||
// 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!!
|
||||
// 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._signal("input", {});
|
||||
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
|
||||
if (this.session && this.session.bgTokenizer)
|
||||
this.session.bgTokenizer.scheduleStart();
|
||||
}.bind(this));
|
||||
|
||||
this.on("change", function(_, _self) {
|
||||
|
|
@ -380,6 +381,9 @@ var Editor = function(renderer, session) {
|
|||
this.onChangeAnnotation();
|
||||
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
||||
this.renderer.updateFull();
|
||||
} else {
|
||||
this.selection = null;
|
||||
this.renderer.setSession(session);
|
||||
}
|
||||
|
||||
this._signal("changeSession", {
|
||||
|
|
@ -2517,6 +2521,9 @@ var Editor = function(renderer, session) {
|
|||
this.destroy = function() {
|
||||
this.renderer.destroy();
|
||||
this._signal("destroy", this);
|
||||
if (this.session) {
|
||||
this.session.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ var Gutter = function(parentEl) {
|
|||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
this.session = session;
|
||||
session.on("change", this.$updateAnnotations);
|
||||
if (session)
|
||||
session.on("change", this.$updateAnnotations);
|
||||
};
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ var Text = function(parentEl) {
|
|||
};
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
this.$computeTabString();
|
||||
if (session)
|
||||
this.$computeTabString();
|
||||
};
|
||||
|
||||
this.showInvisibles = false;
|
||||
|
|
|
|||
|
|
@ -858,12 +858,12 @@ function isSamePoint(p1, p2) {
|
|||
// adds multicursor support to a session
|
||||
exports.onSessionChange = function(e) {
|
||||
var session = e.session;
|
||||
if (!session.multiSelect) {
|
||||
if (session && !session.multiSelect) {
|
||||
session.$selectionMarkers = [];
|
||||
session.selection.$initRangeList();
|
||||
session.multiSelect = session.selection;
|
||||
}
|
||||
this.multiSelect = session.multiSelect;
|
||||
this.multiSelect = session && session.multiSelect;
|
||||
|
||||
var oldSession = e.oldSession;
|
||||
if (oldSession) {
|
||||
|
|
@ -875,16 +875,16 @@ exports.onSessionChange = function(e) {
|
|||
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
|
||||
}
|
||||
|
||||
session.multiSelect.on("addRange", this.$onAddRange);
|
||||
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
||||
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
||||
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
||||
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
||||
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
||||
|
||||
// this.$onSelectionChange = this.onSelectionChange.bind(this);
|
||||
if (session) {
|
||||
session.multiSelect.on("addRange", this.$onAddRange);
|
||||
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
||||
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
||||
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
||||
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
||||
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
||||
}
|
||||
|
||||
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
||||
if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
||||
if (session.selection.inMultiSelectMode)
|
||||
this.$onMultiSelect();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -232,10 +232,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
|
||||
|
||||
this.session = session;
|
||||
if (!session)
|
||||
return;
|
||||
|
||||
if (this.scrollMargin.top && session.getScrollTop() <= 0)
|
||||
if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
|
||||
session.setScrollTop(-this.scrollMargin.top);
|
||||
|
||||
this.$cursorLayer.setSession(session);
|
||||
|
|
@ -243,6 +240,9 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$markerFront.setSession(session);
|
||||
this.$gutterLayer.setSession(session);
|
||||
this.$textLayer.setSession(session);
|
||||
if (!session)
|
||||
return;
|
||||
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
this.session.$setFontMetrics(this.$fontMetrics);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue