mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-01 03:38:53 +08:00
Explicitly dispose Monaco editor instance when cell is deleted (#232)
This commit is contained in:
parent
faeedcefc5
commit
c498cfb211
2 changed files with 18 additions and 0 deletions
|
@ -83,6 +83,10 @@ const Cell = {
|
|||
|
||||
destroyed() {
|
||||
globalPubSub.unsubscribe("session", this.handleSessionEvent);
|
||||
|
||||
if (this.state.liveEditor) {
|
||||
this.state.liveEditor.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
updated() {
|
||||
|
|
|
@ -71,6 +71,20 @@ class LiveEditor {
|
|||
.pushEditOperations([], [{ forceMoveMarkers: true, range, text }]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs necessary cleanup actions.
|
||||
*/
|
||||
destroy() {
|
||||
// Explicitly destroy the editor instance and its text model.
|
||||
this.editor.dispose();
|
||||
|
||||
const model = this.editor.getModel();
|
||||
|
||||
if (model) {
|
||||
model.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
__mountEditor() {
|
||||
this.editor = monaco.editor.create(this.container, {
|
||||
language: this.type,
|
||||
|
|
Loading…
Reference in a new issue