diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 0958e27ce..3ee268b95 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -114,9 +114,6 @@ class TextEditor extends Model throw error state.buffer = state.tokenizedBuffer.buffer - if state.displayLayer = state.buffer.getDisplayLayer(state.displayLayerId) - state.selectionsMarkerLayer = state.displayLayer.getMarkerLayer(state.selectionsMarkerLayerId) - state.assert = atomEnvironment.assert.bind(atomEnvironment) editor = new this(state) if state.registered @@ -167,22 +164,24 @@ class TextEditor extends Model grammar, tabLength, @buffer, @largeFileMode, @assert }) - displayLayerParams = { - invisibles: @getInvisibles(), - softWrapColumn: @getSoftWrapColumn(), - showIndentGuides: not @isMini() and @doesShowIndentGuide(), - atomicSoftTabs: params.atomicSoftTabs ? true, - tabLength: tabLength, - ratioForCharacter: @ratioForCharacter.bind(this), - isWrapBoundary: isWrapBoundary, - foldCharacter: ZERO_WIDTH_NBSP, - softWrapHangingIndent: params.softWrapHangingIndentLength ? 0 - } + unless @displayLayer? + displayLayerParams = { + invisibles: @getInvisibles(), + softWrapColumn: @getSoftWrapColumn(), + showIndentGuides: not @isMini() and @doesShowIndentGuide(), + atomicSoftTabs: params.atomicSoftTabs ? true, + tabLength: tabLength, + ratioForCharacter: @ratioForCharacter.bind(this), + isWrapBoundary: isWrapBoundary, + foldCharacter: ZERO_WIDTH_NBSP, + softWrapHangingIndent: params.softWrapHangingIndentLength ? 0 + } - if @displayLayer? - @displayLayer.reset(displayLayerParams) - else - @displayLayer = @buffer.addDisplayLayer(displayLayerParams) + if @displayLayer = @buffer.getDisplayLayer(params.displayLayerId) + @displayLayer.reset(displayLayerParams) + @selectionsMarkerLayer = @displayLayer.getMarkerLayer(params.selectionsMarkerLayerId) + else + @displayLayer = @buffer.addDisplayLayer(displayLayerParams) @backgroundWorkHandle = requestIdleCallback(@doBackgroundWork) @disposables.add new Disposable =>