fix reattaching linewidgets to editor
This commit is contained in:
parent
6c0bc56500
commit
a1042e0d94
3 changed files with 12 additions and 16 deletions
|
|
@ -96,9 +96,6 @@ require("ace/commands/default_commands").commands.push({
|
|||
|
||||
editor.keyBinding.addKeyboardHandler(kb);
|
||||
inlineEditor.keyBinding.addKeyboardHandler(kb);
|
||||
editor.on("changeSession", function(e) {
|
||||
w.el.parentNode && w.el.parentNode.removeChild(w.el);
|
||||
});
|
||||
inlineEditor.setTheme("ace/theme/solarized_light");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ exports.singleLineEditor = function(el) {
|
|||
|
||||
renderer.setStyle("ace_one-line");
|
||||
var editor = new Editor(renderer);
|
||||
new MultiSelect(editor);
|
||||
editor.session.setUndoManager(new UndoManager());
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@ function LineWidgets(session) {
|
|||
this.renderWidgets = this.renderWidgets.bind(this);
|
||||
this.measureWidgets = this.measureWidgets.bind(this);
|
||||
this.session._changedWidgets = [];
|
||||
this.detach = this.detach.bind(this);
|
||||
this.$onChangeEditor = this.$onChangeEditor.bind(this);
|
||||
|
||||
this.session.on("change", this.updateOnChange);
|
||||
this.session.on("changeEditor", this.$onChangeEditor);
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
|
@ -73,8 +74,12 @@ function LineWidgets(session) {
|
|||
return screenRows;
|
||||
};
|
||||
|
||||
this.$onChangeEditor = function(e) {
|
||||
this.attach(e.editor);
|
||||
};
|
||||
|
||||
this.attach = function(editor) {
|
||||
if (editor.widgetManager && editor.widgetManager != this)
|
||||
if (editor && editor.widgetManager && editor.widgetManager != this)
|
||||
editor.widgetManager.detach();
|
||||
|
||||
if (this.editor == editor)
|
||||
|
|
@ -83,21 +88,16 @@ function LineWidgets(session) {
|
|||
this.detach();
|
||||
this.editor = editor;
|
||||
|
||||
this.editor.on("changeSession", this.detach);
|
||||
|
||||
editor.widgetManager = this;
|
||||
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
if (editor) {
|
||||
editor.widgetManager = this;
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
}
|
||||
};
|
||||
this.detach = function(e) {
|
||||
if (e && e.session == this.session)
|
||||
return; // sometimes attach can be called before setSession
|
||||
var editor = this.editor;
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
editor.off("changeSession", this.detach);
|
||||
|
||||
this.editor = null;
|
||||
editor.widgetManager = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue