diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 514a51625..23b658c04 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -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) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 79eff09cd..e09f1580c 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -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