Now we can force line wrapping in specs without editor being on the DOM.

This commit is contained in:
Nathan Sobo 2012-03-13 15:56:24 -06:00
parent 06a3f3d376
commit 5709b0d152
2 changed files with 6 additions and 8 deletions

View File

@ -567,9 +567,7 @@ describe "Editor", ->
describe "when editing a line that spans multiple screen lines", ->
beforeEach ->
editor.attachToDom()
editor.setSoftWrap(true)
setEditorWidthInChars(editor, 50)
editor.setSoftWrap(true, 50)
describe "when newline is inserted", ->
it "indents cursor based on the indentation of previous buffer line", ->

View File

@ -236,20 +236,20 @@ class Editor extends View
toggleSoftWrap: ->
@setSoftWrap(not @softWrap)
setMaxLineLength: (maxLength) ->
maxLength ?=
setMaxLineLength: (maxLineLength) ->
maxLineLength ?=
if @softWrap
Math.floor(@horizontalScroller.width() / @charWidth)
else
Infinity
@renderer.setMaxLineLength(maxLength) if maxLength
@renderer.setMaxLineLength(maxLineLength) if maxLineLength
createFold: (range) ->
@renderer.createFold(range)
setSoftWrap: (@softWrap) ->
@setMaxLineLength()
setSoftWrap: (@softWrap, maxLineLength=undefined) ->
@setMaxLineLength(maxLineLength)
if @softWrap
@addClass 'soft-wrap'
@_setMaxLineLength = => @setMaxLineLength()