Editor.renderedLines' css width is set to 100% when editor.maxScreenLineLength() is less than Editor.scrollView's width

This commit is contained in:
Corey Johnson
2012-07-16 09:14:33 -07:00
parent 23b42faa1d
commit e089b74867
4 changed files with 15 additions and 9 deletions

View File

@@ -1241,9 +1241,11 @@ describe "Editor", ->
expect(editor.renderedLines.find(".line:last").text()).toBe buffer.lineForRow(6)
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)", ->
maxLineLength = editor.maxScreenLineLength()
setEditorWidthInChars(editor, maxLineLength)
widthBefore = editor.renderedLines.width()
expect(widthBefore).toBe editor.scrollView.width()
buffer.change([[12,0], [12,0]], [1..50].join(''))
buffer.change([[12,0], [12,0]], [1..maxLineLength*2].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan widthBefore
describe "when lines are removed", ->
@@ -1251,6 +1253,15 @@ describe "Editor", ->
editor.attachToDom(heightInLines: 5)
spyOn(editor, "scrollTo")
it "sets the rendered screen line's width to either the max line length or the scollView's width (whichever is greater)", ->
maxLineLength = editor.maxScreenLineLength()
setEditorWidthInChars(editor, maxLineLength)
buffer.change([[12,0], [12,0]], [1..maxLineLength*2].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan editor.scrollView.width()
widthBefore = editor.renderedLines.width()
buffer.delete([[12, 0], [12, Infinity]])
expect(editor.renderedLines.width()).toBe editor.scrollView.width()
describe "when the change the precedes the first rendered row", ->
it "removes rendered lines to account for upstream change", ->
editor.scrollToBottom()
@@ -1321,13 +1332,6 @@ describe "Editor", ->
expect(editor.find('.line').length).toBe 7
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([[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", ->
editor.lineOverdraw = 1

View File

@@ -125,6 +125,7 @@ window.tokensText = (tokens) ->
window.setEditorWidthInChars = (editor, widthInChars, charWidth=editor.charWidth) ->
editor.width(charWidth * widthInChars + editor.renderedLines.position().left)
$(window).trigger 'resize' # update width of editor's on-screen lines
window.setEditorHeightInLines = (editor, heightInChars, charHeight=editor.lineHeight) ->
editor.height(charHeight * heightInChars + editor.renderedLines.position().top)

View File

@@ -657,7 +657,7 @@ class Editor extends View
if width > @scrollView.width()
@renderedLines.width(width)
else
@renderedLines.width(@scrollView.width())
@renderedLines.width("inherit")
handleScrollHeightChange: ->
scrollHeight = @lineHeight * @screenLineCount()

View File

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