From d44c648d4b4b38b6b9ce02b546a216d802d16067 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 13 Jul 2012 09:05:38 -0700 Subject: [PATCH] Editor.renderedLines' width is set to the maximum of either Editor.scrollView's width or the maximum rendered line width --- spec/app/editor-spec.coffee | 11 +++++++---- src/app/editor.coffee | 6 +++++- static/editor.css | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index bce9373d3..445471590 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 7d7946fcd..2288251fd 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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() diff --git a/static/editor.css b/static/editor.css index c43298fcb..c4edec6e3 100644 --- a/static/editor.css +++ b/static/editor.css @@ -66,7 +66,6 @@ .editor .lines { position: relative; display: table; - width: 100%; height: 100%; }