Merge pull request #1623 from atom/ns-fix-editor-width-related-freezes

Fix freezes related to the editor's width in characters being assigned to non-positive integers
This commit is contained in:
Nathan Sobo
2014-02-28 20:38:07 +02:00
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')