Editor.renderedLines' width is set to the maximum of either Editor.scrollView's width or the maximum rendered line width

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-07-13 09:05:38 -07:00
parent c39172d625
commit d44c648d4b
3 changed files with 12 additions and 6 deletions

View File

@ -1239,8 +1239,9 @@ describe "Editor", ->
expect(editor.renderedLines.find(".line:first").text()).toBe buffer.lineForRow(0)
expect(editor.renderedLines.find(".line:last").text()).toBe buffer.lineForRow(6)
it "increases the width of the rendered lines element if the max line length changes", ->
it "increases the width of the rendered lines element to be either the width of the longest line or the width of the scrollView (whichever is longer)", ->
widthBefore = editor.renderedLines.width()
expect(widthBefore).toBe editor.scrollView.width()
buffer.change([[12,0], [12,0]], [1..50].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan widthBefore
@ -1319,10 +1320,12 @@ describe "Editor", ->
expect(editor.find('.line').length).toBe 7
it "decreases the width of the rendered screen lines if the max line length changes", ->
it "sets the rendered screen line's width to either the max line length or the scollView's width (whichever is greater)", ->
buffer.change([[12,0], [12,0]], [1..100].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan editor.scrollView.width()
widthBefore = editor.renderedLines.width()
buffer.delete([[6, 0], [6, Infinity]])
expect(editor.renderedLines.width()).toBeLessThan widthBefore
buffer.delete([[12, 0], [12, Infinity]])
expect(editor.renderedLines.width()).toBe editor.scrollView.width()
describe "when folding leaves less then a screen worth of text (regression)", ->
it "renders lines properly", ->

View File

@ -650,7 +650,11 @@ class Editor extends View
@renderedLines.css('padding-bottom', heightOfRenderedLines)
adjustWidthOfRenderedLines: ->
@renderedLines.width(@charWidth * @maxScreenLineLength())
width = @charWidth * @maxScreenLineLength()
if width > @scrollView.width()
@renderedLines.width(width)
else
@renderedLines.width(@scrollView.width())
handleScrollHeightChange: ->
scrollHeight = @lineHeight * @screenLineCount()

View File

@ -66,7 +66,6 @@
.editor .lines {
position: relative;
display: table;
width: 100%;
height: 100%;
}