Only allow positive widths in characters to be assigned

Fixes #1574
This commit is contained in:
Nathan Sobo
2014-02-28 10:31:02 -08:00
parent d660e9a066
commit 4681098e8c
2 changed files with 11 additions and 4 deletions

View File

@@ -200,6 +200,12 @@ describe "DisplayBuffer", ->
expect(tokensText displayBuffer.lineForRow(12).tokens).toBe 'sort(left).concat(pivot).concat(sort(rig'
expect(changeHandler).toHaveBeenCalledWith(start: 0, end: 15, screenDelta: 3, bufferDelta: 0)
it "only allows positive widths to be assigned", ->
displayBuffer.setEditorWidthInChars(0)
expect(displayBuffer.editorWidthInChars).not.toBe 0
displayBuffer.setEditorWidthInChars(-1)
expect(displayBuffer.editorWidthInChars).not.toBe -1
describe "primitive folding", ->
beforeEach ->
displayBuffer.destroy()

View File

@@ -99,10 +99,11 @@ class DisplayBuffer extends Model
#
# editorWidthInChars - A {Number} of characters.
setEditorWidthInChars: (editorWidthInChars) ->
previousWidthInChars = @editorWidthInChars
@editorWidthInChars = editorWidthInChars
if editorWidthInChars isnt previousWidthInChars and @softWrap
@updateWrappedScreenLines()
if editorWidthInChars > 0
previousWidthInChars = @editorWidthInChars
@editorWidthInChars = editorWidthInChars
if editorWidthInChars isnt previousWidthInChars and @softWrap
@updateWrappedScreenLines()
getSoftWrapColumn: ->
if atom.config.get('editor.softWrapAtPreferredLineLength')