mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Add TextEditorPresenter::state.gutter.visible
This commit is contained in:
parent
fd603a0cbc
commit
156569f19e
@ -1970,6 +1970,28 @@ describe "TextEditorPresenter", ->
|
||||
editor.undo()
|
||||
expect(lineNumberStateForScreenRow(presenter, 11).foldable).toBe false
|
||||
|
||||
describe ".visible", ->
|
||||
it "is true iff the editor isn't mini, ::isGutterVisible is true on the editor, and 'editor.showLineNumbers' is enabled in config", ->
|
||||
presenter = buildPresenter()
|
||||
|
||||
expect(editor.isGutterVisible()).toBe true
|
||||
expect(presenter.state.gutter.visible).toBe true
|
||||
|
||||
expectStateUpdate presenter, -> editor.setMini(true)
|
||||
expect(presenter.state.gutter.visible).toBe false
|
||||
|
||||
expectStateUpdate presenter, -> editor.setMini(false)
|
||||
expect(presenter.state.gutter.visible).toBe true
|
||||
|
||||
expectStateUpdate presenter, -> editor.setGutterVisible(false)
|
||||
expect(presenter.state.gutter.visible).toBe false
|
||||
|
||||
expectStateUpdate presenter, -> editor.setGutterVisible(true)
|
||||
expect(presenter.state.gutter.visible).toBe true
|
||||
|
||||
expectStateUpdate presenter, -> atom.config.set('editor.showLineNumbers', false)
|
||||
expect(presenter.state.gutter.visible).toBe false
|
||||
|
||||
describe ".height", ->
|
||||
it "tracks the computed content height if ::autoHeight is true so the editor auto-expands vertically", ->
|
||||
presenter = buildPresenter(explicitHeight: null, autoHeight: true)
|
||||
|
@ -64,7 +64,10 @@ class TextEditorPresenter
|
||||
@updateContentState()
|
||||
@updateDecorations()
|
||||
@updateLinesState()
|
||||
@updateGutterState()
|
||||
@updateLineNumbersState()
|
||||
@disposables.add @model.onDidChangeGutterVisible =>
|
||||
@updateGutterState()
|
||||
@disposables.add @model.onDidAddDecoration(@didAddDecoration.bind(this))
|
||||
@disposables.add @model.onDidAddCursor(@didAddCursor.bind(this))
|
||||
@disposables.add @model.onDidChangeScrollTop(@setScrollTop.bind(this))
|
||||
@ -74,6 +77,7 @@ class TextEditorPresenter
|
||||
|
||||
observeConfig: ->
|
||||
@scrollPastEnd = atom.config.get('editor.scrollPastEnd')
|
||||
@showLineNumbers = atom.config.get('editor.showLineNumbers')
|
||||
|
||||
@disposables.add atom.config.onDidChange 'editor.showIndentGuide', scope: @model.getRootScopeDescriptor(), @updateContentState.bind(this)
|
||||
@disposables.add atom.config.onDidChange 'editor.scrollPastEnd', scope: @model.getRootScopeDescriptor(), ({newValue}) =>
|
||||
@ -81,6 +85,9 @@ class TextEditorPresenter
|
||||
@updateScrollHeight()
|
||||
@updateVerticalScrollState()
|
||||
@updateScrollbarsState()
|
||||
@disposables.add atom.config.onDidChange 'editor.showLineNumbers', scope: @model.getRootScopeDescriptor(), ({newValue}) =>
|
||||
@showLineNumbers = newValue
|
||||
@updateGutterState()
|
||||
|
||||
buildState: ->
|
||||
@state =
|
||||
@ -269,6 +276,7 @@ class TextEditorPresenter
|
||||
@emitter.emit "did-update-state"
|
||||
|
||||
updateGutterState: ->
|
||||
@state.gutter.visible = not @model.isMini() and (@model.isGutterVisible() ? true) and @showLineNumbers
|
||||
@state.gutter.maxLineNumberDigits = @model.getLineCount().toString().length
|
||||
@state.gutter.backgroundColor = if @gutterBackgroundColor isnt "rgba(0, 0, 0, 0)"
|
||||
@gutterBackgroundColor
|
||||
|
Loading…
Reference in New Issue
Block a user