From 994756f8c1aa19326d4901d84e79d3fe93dcc965 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 5 Nov 2013 18:30:59 -0800 Subject: [PATCH 1/6] Use padding in the pixel left calculation Now themes can specify padding in the scroll-view so the text isn't jammed up against the --- src/editor.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/editor.coffee b/src/editor.coffee index 538da45da..edb16cdb5 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -1596,6 +1596,9 @@ class Editor extends View returnLeft = null + offsetLeft = @scrollView.offset().left + paddingLeft = parseInt(@scrollView.css('padding-left')) + while textNode = iterator.nextNode() content = textNode.textContent @@ -1618,7 +1621,7 @@ class Editor extends View MeasureRange.collapse() rects = MeasureRange.getClientRects() return 0 if rects.length == 0 - left = rects[0].left - Math.floor(@scrollView.offset().left) + Math.floor(@scrollLeft()) + left = rects[0].left - Math.floor(offsetLeft) + Math.floor(@scrollLeft()) - paddingLeft if scopes? cachedCharWidth = left - oldLeft From 0aa0dc01d57d441bed6a617a2108a4f0f2e94198 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 5 Nov 2013 18:39:11 -0800 Subject: [PATCH 2/6] Properly reset the size of layers on resize Otherwise, when a theme has padding in the scroll-view, it will be scrollable all the time (width:100%). --- src/editor.coffee | 3 ++- static/editor.less | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/editor.coffee b/src/editor.coffee index edb16cdb5..ae5ea8557 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -774,6 +774,7 @@ class Editor extends View @setHeightInLines() @setWidthInChars() @requestDisplayUpdate() + @updateLayerDimensions() @focus() if @isFocused if pane = @getPane() @@ -1155,7 +1156,7 @@ class Editor extends View @verticalScrollbarContent.height(@layerHeight) @scrollBottom(height) if @scrollBottom() > height - minWidth = @charWidth * @getMaxScreenLineLength() + 20 + minWidth = @scrollView.width() unless @layerMinWidth == minWidth @renderedLines.css('min-width', minWidth) @underlayer.css('min-width', minWidth) diff --git a/static/editor.less b/static/editor.less index 912f9503d..c4b762ace 100644 --- a/static/editor.less +++ b/static/editor.less @@ -101,12 +101,6 @@ overflow-x: hidden; } -.editor .underlayer, -.editor .lines, -.editor .overlayer { - width: 100%; -} - .editor .underlayer { z-index: 0; position: absolute; From 6e049dd1733b5d2b722162441dd75d49b7a9ab27 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 6 Nov 2013 14:13:09 -0800 Subject: [PATCH 3/6] Fix tests in editor --- spec/editor-spec.coffee | 5 ++++- src/editor.coffee | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 72f85dc46..c0d8cb8ba 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -777,6 +777,9 @@ describe "Editor", -> # resizes with the editor expect(editor.width()).toBeLessThan(800) editor.width(800) + editor.resize() # call to trigger the resize event. + + region2 = selectionView.regions[1] expect(region2.width()).toBe(editor.renderedLines.outerWidth()) region3 = selectionView.regions[2] @@ -1332,7 +1335,7 @@ describe "Editor", -> setEditorWidthInChars(editor, maxLineLength) widthBefore = editor.renderedLines.width() expect(widthBefore).toBe editor.scrollView.width() + 20 - buffer.change([[12,0], [12,0]], [1..maxLineLength*2].join('')) + buffer.change([[12,0], [12,0]], [1..maxLineLength*10].join('')) expect(editor.renderedLines.width()).toBeGreaterThan widthBefore describe "when lines are removed", -> diff --git a/src/editor.coffee b/src/editor.coffee index ae5ea8557..9ebf10138 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -773,8 +773,8 @@ class Editor extends View @subscribe $(window), "resize.editor-#{@id}", => @setHeightInLines() @setWidthInChars() - @requestDisplayUpdate() @updateLayerDimensions() + @requestDisplayUpdate() @focus() if @isFocused if pane = @getPane() @@ -1156,7 +1156,7 @@ class Editor extends View @verticalScrollbarContent.height(@layerHeight) @scrollBottom(height) if @scrollBottom() > height - minWidth = @scrollView.width() + minWidth = Math.max(@charWidth * @getMaxScreenLineLength() + 20, @scrollView.width()) unless @layerMinWidth == minWidth @renderedLines.css('min-width', minWidth) @underlayer.css('min-width', minWidth) From 0f1d701646b4441ef5ba3afa0673fafb736722a1 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 6 Nov 2013 14:21:54 -0800 Subject: [PATCH 4/6] Upgrade to wrap-guide@0.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9b69ceab..72c7f983d 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "tree-view": "0.28.0", "visual-bell": "0.3.0", "whitespace": "0.8.0", - "wrap-guide": "0.4.0", + "wrap-guide": "0.5.0", "language-c": "0.2.0", "language-clojure": "0.1.0", From 2adcc9709c8c1122d166322ae37b7a145d6e9469 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 6 Nov 2013 14:37:36 -0800 Subject: [PATCH 5/6] 10 -> back to 2 --- spec/editor-spec.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index c0d8cb8ba..0eb35125e 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -1330,12 +1330,12 @@ 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 to be either the width of the longest line or the width of the scrollView (whichever is longer)", -> + ffit "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.getMaxScreenLineLength() setEditorWidthInChars(editor, maxLineLength) widthBefore = editor.renderedLines.width() expect(widthBefore).toBe editor.scrollView.width() + 20 - buffer.change([[12,0], [12,0]], [1..maxLineLength*10].join('')) + buffer.change([[12,0], [12,0]], [1..maxLineLength*2].join('')) expect(editor.renderedLines.width()).toBeGreaterThan widthBefore describe "when lines are removed", -> From 16b64b03f7f8d6576354394d18a985cff64e2016 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 6 Nov 2013 14:38:01 -0800 Subject: [PATCH 6/6] Nof --- spec/editor-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 0eb35125e..4959ce27d 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -1330,7 +1330,7 @@ describe "Editor", -> expect(editor.renderedLines.find(".line:first").text()).toBe buffer.lineForRow(0) expect(editor.renderedLines.find(".line:last").text()).toBe buffer.lineForRow(6) - ffit "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)", -> + 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.getMaxScreenLineLength() setEditorWidthInChars(editor, maxLineLength) widthBefore = editor.renderedLines.width()