Editor only renders lines when it is attached to the DOM

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-05-09 19:19:54 -06:00
parent b369c09fa0
commit 5ae40a3cb8
2 changed files with 28 additions and 13 deletions

View File

@@ -214,6 +214,7 @@ class Editor extends View
@attached = true
@subscribeToFontSize()
@calculateDimensions()
@renderLines()
@hiddenInput.width(@charWidth)
@setMaxLineLength() if @softWrap
@focus() if @isFocused
@@ -258,7 +259,7 @@ class Editor extends View
@buffer.on "path-change.editor#{@id}", => @trigger 'editor-path-change'
@renderer = new Renderer(@buffer, { maxLineLength: @calcMaxLineLength(), tabText: @tabText })
@renderLines()
@renderLines() if @attached
@gutter.renderLineNumbers()
@loadEditSessionForBuffer(@buffer)
@@ -316,8 +317,9 @@ class Editor extends View
@compositeCursor.updateBufferPosition() unless e.bufferChanged
lineElements = @buildLineElements(newRange.start.row, newRange.end.row)
@replaceLineElements(oldRange.start.row, oldRange.end.row, lineElements)
if @attached
lineElements = @buildLineElements(newRange.start.row, newRange.end.row)
@replaceLineElements(oldRange.start.row, oldRange.end.row, lineElements)
buildLineElements: (startRow, endRow) ->
charWidth = @charWidth
@@ -380,7 +382,7 @@ class Editor extends View
@renderer.createFold(range)
setSoftWrap: (@softWrap, maxLineLength=undefined) ->
@setMaxLineLength(maxLineLength)
@setMaxLineLength(maxLineLength) if @attached
if @softWrap
@addClass 'soft-wrap'
@_setMaxLineLength = => @setMaxLineLength()