From 24ce41528309adf785d4c8b3256cdbc9eddaa779 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 24 Apr 2013 11:29:46 -0700 Subject: [PATCH] Move event listener calls from `resetDisplay` to `edit` Fixes #140 --- spec/app/editor-spec.coffee | 12 ++++++++++++ src/app/editor.coffee | 16 ++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 5e6ed1c5d..2bbb54638 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2575,3 +2575,15 @@ describe "Editor", -> editor.on 'editor:will-be-removed', willBeRemovedHandler editor.getPane().destroyActiveItem() expect(willBeRemovedHandler).toHaveBeenCalled() + + + describe "when setInvisibles is toggled (regression)", -> + it "renders inserted newlines properly", -> + editor.setShowInvisibles(true) + editor.setCursorBufferPosition([0, 0]) + editor.attachToDom(heightInLines: 20) + editor.setShowInvisibles(false) + editor.insertText("\n") + + for rowNumber in [1..5] + expect(editor.lineElementForScreenRow(rowNumber).text()).toBe buffer.lineForRow(rowNumber) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 516ce797a..e04c409d3 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -826,6 +826,14 @@ class Editor extends View @activeEditSession.on "grammar-changed.editor", => @trigger 'editor:grammar-changed' + @activeEditSession.on 'selection-added.editor', (selection) => + @newCursors.push(selection.cursor) + @newSelections.push(selection) + @requestDisplayUpdate() + + @activeEditSession.on 'screen-lines-changed.editor', (e) => + @handleScreenLinesChange(e) + @trigger 'editor:path-changed' @resetDisplay() @@ -1178,14 +1186,6 @@ class Editor extends View @removeAllCursorAndSelectionViews() @updateLayerDimensions() @setScrollPositionFromActiveEditSession() - - @activeEditSession.on 'selection-added.editor', (selection) => - @newCursors.push(selection.cursor) - @newSelections.push(selection) - @requestDisplayUpdate() - - @activeEditSession.on 'screen-lines-changed.editor', (e) => @handleScreenLinesChange(e) - @newCursors = @activeEditSession.getCursors() @newSelections = @activeEditSession.getSelections() @updateDisplay(suppressAutoScroll: true)