From 6c7e942470896e8266050231e37cb7f6ec78e161 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 5 Jul 2018 14:25:58 +0100 Subject: [PATCH] Unbind unload listener when destroying editor --- .../public/coffee/ide/editor/directives/aceEditor.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index ef6db538c4..b92e7bfb0c 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -386,15 +386,18 @@ define [ e.oldSession?.selection.off 'changeCursor', cursorPositionManager.onCursorChange e.session.selection.on 'changeCursor', cursorPositionManager.onCursorChange + onUnloadForCursorPosition = () -> + cursorPositionManager.onUnload(editor.getSession()) + initCursorPosition = () -> cursorPositionManager.init() editor.on 'changeSession', onSessionChangeForCursorPosition onSessionChangeForCursorPosition({ session: editor.getSession() }) # Force initial setup - $(window).on "unload", () -> - cursorPositionManager.onUnload(editor.getSession()) + $(window).on "unload", onUnloadForCursorPosition tearDownCursorPosition = () -> editor.off 'changeSession', onSessionChangeForCursorPosition + $(window).off "unload", onUnloadForCursorPosition attachToAce = (sharejs_doc) -> lines = sharejs_doc.getSnapshot().split("\n")