From 7b4bc165316d66b53550afb26b2300a83542280d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 23 Apr 2014 18:40:29 -0600 Subject: [PATCH] Fix specs that broke when accounting for horizontal scrollbar height --- spec/display-buffer-spec.coffee | 2 ++ spec/editor-spec.coffee | 3 +++ src/display-buffer.coffee | 5 ++++- src/editor.coffee | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 2d1eaca30..4abce359a 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -979,6 +979,7 @@ describe "DisplayBuffer", -> describe "::setScrollLeft", -> beforeEach -> displayBuffer.manageScrollPosition = true + displayBuffer.setLineHeight(10) displayBuffer.setDefaultCharWidth(10) it "disallows negative values", -> @@ -1001,6 +1002,7 @@ describe "DisplayBuffer", -> displayBuffer.manageScrollPosition = true displayBuffer.setLineHeight(10) displayBuffer.setDefaultCharWidth(10) + displayBuffer.setHorizontalScrollbarHeight(0) displayBuffer.setHeight(50) displayBuffer.setWidth(50) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 91a282f55..d7f214f22 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -698,6 +698,7 @@ describe "Editor", -> editor.setHorizontalScrollMargin(2) editor.setLineHeight(10) editor.setDefaultCharWidth(10) + editor.setHorizontalScrollbarHeight(0) editor.setHeight(5.5 * 10) editor.setWidth(5.5 * 10) @@ -1138,6 +1139,7 @@ describe "Editor", -> editor.setDefaultCharWidth(10) editor.setHeight(50) editor.setWidth(50) + editor.setHorizontalScrollbarHeight(0) expect(editor.getScrollTop()).toBe 0 editor.setSelectedBufferRange([[5, 6], [6, 8]], autoscroll: true) @@ -3098,6 +3100,7 @@ describe "Editor", -> editor.setDefaultCharWidth(10) editor.setHeight(50) editor.setWidth(50) + editor.setHorizontalScrollbarHeight(0) expect(editor.getScrollTop()).toBe 0 expect(editor.getScrollLeft()).toBe 0 diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 73384c367..c4c492712 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -32,6 +32,7 @@ class DisplayBuffer extends Model verticalScrollMargin: 2 horizontalScrollMargin: 6 + horizontalScrollbarHeight: 15 constructor: ({tabLength, @editorWidthInChars, @tokenizedBuffer, buffer}={}) -> super @@ -126,7 +127,9 @@ class DisplayBuffer extends Model verticallyScrollable: -> @getScrollHeight() > @getClientHeight() - getHorizontalScrollbarHeight: -> 15 + getHorizontalScrollbarHeight: -> @horizontalScrollbarHeight + + setHorizontalScrollbarHeight: (@horizontalScrollbarHeight) -> @horizontalScrollbarHeight getWidth: -> @width ? @getScrollWidth() diff --git a/src/editor.coffee b/src/editor.coffee index 5ed5b32bd..d17a03697 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -1895,6 +1895,8 @@ class Editor extends Model verticallyScrollable: -> @displayBuffer.verticallyScrollable() + setHorizontalScrollbarHeight: (height) -> @displayBuffer.setHorizontalScrollbarHeight(height) + # Deprecated: Call {::joinLines} instead. joinLine: -> deprecate("Use Editor::joinLines() instead")