Hide scrollbars on mini editors

Fixes #5548
This commit is contained in:
Nathan Sobo
2015-02-13 19:37:27 -07:00
parent 9517410ef4
commit 55a70da3cf
2 changed files with 20 additions and 4 deletions

View File

@@ -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)

View File

@@ -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