From e089b74867bb837ab712f17db058878c32bde55e Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 16 Jul 2012 09:14:33 -0700 Subject: [PATCH] Editor.renderedLines' css width is set to 100% when editor.maxScreenLineLength() is less than Editor.scrollView's width --- spec/app/editor-spec.coffee | 20 ++++++++++++-------- spec/spec-helper.coffee | 1 + src/app/editor.coffee | 2 +- static/editor.css | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index f88789f89..3f4316504 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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 diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 5ff852fcc..672e1e5a9 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -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) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 7fe8edba2..4d2b9f3b9 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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() diff --git a/static/editor.css b/static/editor.css index c4edec6e3..e4816f26b 100644 --- a/static/editor.css +++ b/static/editor.css @@ -67,6 +67,7 @@ position: relative; display: table; height: 100%; + width: 100%; } .editor .line {