From 55a70da3cf68be175a9df41f5dbc7d4a34b7a67e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 Feb 2015 19:37:27 -0700 Subject: [PATCH] Hide scrollbars on mini editors Fixes #5548 --- spec/text-editor-presenter-spec.coffee | 12 ++++++++++++ src/text-editor-presenter.coffee | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index f77a6862c..b1ee17ef1 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -77,6 +77,18 @@ describe "TextEditorPresenter", -> presenter.setExplicitHeight((editor.getLineCount() * 10) - 1) expect(state.horizontalScrollbar.visible).toBe true + it "is false if the editor is mini", -> + presenter = buildPresenter + explicitHeight: editor.getLineCount() * 10 + contentFrameWidth: editor.getMaxScreenLineLength() * 10 - 10 + baseCharacterWidth: 10 + + expect(presenter.state.horizontalScrollbar.visible).toBe true + editor.setMini(true) + expect(presenter.state.horizontalScrollbar.visible).toBe false + editor.setMini(false) + expect(presenter.state.horizontalScrollbar.visible).toBe true + describe ".height", -> it "tracks the value of ::horizontalScrollbarHeight", -> presenter = buildPresenter(horizontalScrollbarHeight: 10) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 04245aade..56a2fad98 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -59,6 +59,8 @@ class TextEditorPresenter @disposables.add @model.onDidChangeGrammar(@updateContentState.bind(this)) @disposables.add @model.onDidChangePlaceholderText(@updateContentState.bind(this)) @disposables.add @model.onDidChangeMini => + @updateScrollbarDimensions() + @updateScrollbarsState() @updateContentState() @updateDecorations() @updateLinesState() @@ -395,12 +397,14 @@ class TextEditorPresenter clientHeightWithHorizontalScrollbar = clientHeightWithoutHorizontalScrollbar - @measuredHorizontalScrollbarHeight horizontalScrollbarVisible = - @contentWidth > clientWidthWithoutVerticalScrollbar or - @contentWidth > clientWidthWithVerticalScrollbar and @contentHeight > clientHeightWithoutHorizontalScrollbar + not @model.isMini() and + (@contentWidth > clientWidthWithoutVerticalScrollbar or + @contentWidth > clientWidthWithVerticalScrollbar and @contentHeight > clientHeightWithoutHorizontalScrollbar) verticalScrollbarVisible = - @contentHeight > clientHeightWithoutHorizontalScrollbar or - @contentHeight > clientHeightWithHorizontalScrollbar and @contentWidth > clientWidthWithoutVerticalScrollbar + not @model.isMini() and + (@contentHeight > clientHeightWithoutHorizontalScrollbar or + @contentHeight > clientHeightWithHorizontalScrollbar and @contentWidth > clientWidthWithoutVerticalScrollbar) horizontalScrollbarHeight = if horizontalScrollbarVisible