From b7b4dcda24536421e9cfd4a738d4b477ee33c3a2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 8 Apr 2013 12:50:05 -0700 Subject: [PATCH] Schedule redraw when updating an invisible editor The redrawOnReattach flag will now be set when update display is called on an invisible editor so that if the editor is detached or hidden before the next update was processed it will be performed when reattached. --- spec/app/editor-spec.coffee | 18 ++++++++++++++++++ src/app/editor.coffee | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index a49088bfd..9fe7e94e0 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2515,3 +2515,21 @@ describe "Editor", -> runs -> expect(editor.renderedLines.find('.line').text()).toBe 'hidden changes' + + it "redraws the editor when it is next reattached", -> + editor.attachToDom() + editor.hide() + editor.setText('hidden changes') + editor.setCursorBufferPosition([0,4]) + editor.detach() + + displayUpdatedHandler = jasmine.createSpy("displayUpdatedHandler") + editor.on 'editor:display-updated', displayUpdatedHandler + editor.show() + editor.attachToDom() + + waitsFor -> + displayUpdatedHandler.callCount is 1 + + runs -> + expect(editor.renderedLines.find('.line').text()).toBe 'hidden changes' diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 37e9610af..5eefef7bb 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -783,7 +783,9 @@ class Editor extends View updateDisplay: (options={}) -> return unless @attached and @activeEditSession return if @activeEditSession.destroyed - return unless @isVisible() + unless @isVisible() + @redrawOnReattach = true + return @updateRenderedLines() @highlightCursorLine()