From d152095920040b80520b57c2ce5b866e78f2af8f Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 15 Sep 2016 14:18:58 +0100 Subject: [PATCH] destroy ace sessions when no longer in use also set mode to "latex" when session is created, to avoid setting mode to "text" (default) and then to "latex" which causes the text worker to be unnecessarily created and destroyed. --- .../public/coffee/ide/editor/directives/aceEditor.coffee | 6 ++++-- 1 file changed, 4 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 b4c15b3539..30c08b9fb4 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -178,7 +178,6 @@ define [ editor.setValue(text, -1) session = editor.getSession() session.setUseWrapMode(true) - session.setMode("ace/mode/latex") scope.$watch "annotations", (annotations) -> session = editor.getSession() @@ -203,7 +202,10 @@ define [ attachToAce = (sharejs_doc) -> lines = sharejs_doc.getSnapshot().split("\n") - editor.setSession(new EditSession(lines)) + session = editor.getSession() + if session? + session.destroy() + editor.setSession(new EditSession(lines, "ace/mode/latex")) resetSession() session = editor.getSession()