DisplayBuffer#getEditorWidthInChars must always be >= 0

This commit is contained in:
Antonio Scandurra
2015-02-27 00:55:03 +01:00
parent 30e3813a71
commit efefc0dc66
2 changed files with 9 additions and 1 deletions

View File

@@ -80,6 +80,14 @@ describe "DisplayBuffer", ->
atom.config.set('editor.softWrapAtPreferredLineLength', false)
expect(displayBuffer.tokenizedLineForScreenRow(10).text).toBe ' return '
describe "when editor width is negative", ->
it "does not hang while wrapping", ->
displayBuffer.setDefaultCharWidth(1)
displayBuffer.setWidth(-1)
expect(displayBuffer.tokenizedLineForScreenRow(1).text).toBe " "
expect(displayBuffer.tokenizedLineForScreenRow(2).text).toBe " var sort = function(items) {"
describe "when the line is shorter than the max line length", ->
it "renders the line unchanged", ->
expect(displayBuffer.tokenizedLineForScreenRow(0).text).toBe buffer.lineForRow(0)

View File

@@ -458,7 +458,7 @@ class DisplayBuffer extends Model
width = @width ? @getScrollWidth()
width -= @getVerticalScrollbarWidth()
if width? and @defaultCharWidth > 0
Math.floor(width / @defaultCharWidth)
Math.max(0, Math.floor(width / @defaultCharWidth))
else
@editorWidthInChars