From c7b71353880acc4387d86ec76073ca41dd34312c Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 13 Jul 2012 17:16:53 -0600 Subject: [PATCH] Temporary fix: When editor is resized, adjust width of rendered lines. We do this to ensure that the lines aren't longer than the scroll view if they don't have to be. We really should use min-width instead because it's automatic. Also, trigger window resize when we make the editor narrower. --- spec/app/editor-spec.coffee | 1 + spec/spec-helper.coffee | 1 + src/app/editor.coffee | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 140c80088..6651fb6c1 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1241,6 +1241,7 @@ 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)", -> + setEditorWidthInChars(editor, editor.maxScreenLineLength()) widthBefore = editor.renderedLines.width() expect(widthBefore).toBe editor.scrollView.width() buffer.change([[12,0], [12,0]], [1..50].join('')) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 62c51b39d..eb82d2c3b 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -142,6 +142,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..9a31078da 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -337,7 +337,9 @@ class Editor extends View @calculateDimensions() @hiddenInput.width(@charWidth) @setSoftWrapColumn() if @activeEditSession.getSoftWrap() - $(window).on "resize.editor#{@id}", => @updateRenderedLines() + $(window).on "resize.editor#{@id}", => + @updateRenderedLines() + @adjustWidthOfRenderedLines() # TODO: This should happen automatically with CSS @focus() if @isFocused @renderWhenAttached()