From fec326672672f0ef7f0850c631e4c9184749254f Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 27 May 2016 14:13:53 +0100 Subject: [PATCH] Don't remove new instance of Document from openDocs when cleaning up old instance --- services/web/public/coffee/ide/editor/Document.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/editor/Document.coffee b/services/web/public/coffee/ide/editor/Document.coffee index 4465d2e2fe..01fa323da2 100644 --- a/services/web/public/coffee/ide/editor/Document.coffee +++ b/services/web/public/coffee/ide/editor/Document.coffee @@ -238,7 +238,14 @@ define [ callback(error) _cleanUp: () -> - delete Document.openDocs[@doc_id] + if Document.openDocs[@doc_id] == @ + sl_console.log "[_cleanUp] Removing self (#{@doc_id}) from in openDocs" + delete Document.openDocs[@doc_id] + else + # It's possible that this instance has error, and the doc has been reloaded. + # This creates a new instance in Document.openDoc with the same id. We shouldn't + # clear it because it's not use. + sl_console.log "[_cleanUp] New instance of (#{@doc_id}) created. Not removing" @_unBindFromEditorEvents() @_unBindFromSocketEvents()