Add content.indentGuidesVisible to TextEditorPresenter::state
Esse commit está contido em:
@@ -29,6 +29,14 @@ describe "TextEditorPresenter", ->
|
||||
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, clientWidth: 10 * maxLineLength + 20, scrollTop: 0, baseCharacterWidth: 10, lineHeight: 10, lineOverdrawMargin: 0)
|
||||
expect(presenter.state.content.scrollWidth).toBe 10 * maxLineLength + 20
|
||||
|
||||
it "assigns .indentGuidesVisible based on the editor.showIndentGuide config setting", ->
|
||||
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, clientWidth: 50, scrollTop: 0, baseCharacterWidth: 10, lineHeight: 10, lineOverdrawMargin: 0)
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe false
|
||||
|
||||
atom.config.set('editor.showIndentGuide', true)
|
||||
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, clientWidth: 50, scrollTop: 0, baseCharacterWidth: 10, lineHeight: 10, lineOverdrawMargin: 0)
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe true
|
||||
|
||||
describe "when the ::clientWidth changes", ->
|
||||
it "updates .scrollWidth", ->
|
||||
maxLineLength = editor.getMaxScreenLineLength()
|
||||
@@ -68,6 +76,17 @@ describe "TextEditorPresenter", ->
|
||||
editor.setSoftWrapped(false)
|
||||
expect(presenter.state.content.scrollWidth).toBe 10 * editor.getMaxScreenLineLength() + 1
|
||||
|
||||
describe "when the editor.showIndentGuide config setting changes", ->
|
||||
it "updates .indentGuidesVisible", ->
|
||||
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, clientWidth: 50, scrollTop: 0, baseCharacterWidth: 10, lineHeight: 10, lineOverdrawMargin: 0)
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe false
|
||||
|
||||
atom.config.set('editor.showIndentGuide', true)
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe true
|
||||
|
||||
atom.config.set('editor.showIndentGuide', false)
|
||||
expect(presenter.state.content.indentGuidesVisible).toBe false
|
||||
|
||||
describe "::state.content.lines", ->
|
||||
describe "on initialization", ->
|
||||
it "contains the lines that are visible on screen, plus the overdraw margin", ->
|
||||
|
||||
@@ -6,25 +6,31 @@ class TextEditorPresenter
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin}) ->
|
||||
@disposables = new CompositeDisposable
|
||||
@charWidthsByScope = {}
|
||||
@subscribeToModel()
|
||||
@observeModel()
|
||||
@observeConfig()
|
||||
@buildState()
|
||||
|
||||
destroy: ->
|
||||
@disposables.dispose()
|
||||
|
||||
subscribeToModel: ->
|
||||
observeModel: ->
|
||||
@disposables.add @model.onDidChange(@updateLinesState.bind(this))
|
||||
@disposables.add @model.onDidChangeSoftWrapped =>
|
||||
@updateContentState()
|
||||
@updateLinesState()
|
||||
|
||||
observeConfig: ->
|
||||
@disposables.add atom.config.onDidChange 'editor.showIndentGuide', @updateContentState.bind(this)
|
||||
|
||||
buildState: ->
|
||||
@state = {}
|
||||
@buildContentState()
|
||||
@buildLinesState()
|
||||
|
||||
buildContentState: ->
|
||||
@state.content = {scrollWidth: @computeScrollWidth()}
|
||||
@state.content =
|
||||
scrollWidth: @computeScrollWidth()
|
||||
indentGuidesVisible: atom.config.get('editor.showIndentGuide')
|
||||
|
||||
buildLinesState: ->
|
||||
@state.content.lines = {}
|
||||
@@ -32,6 +38,7 @@ class TextEditorPresenter
|
||||
|
||||
updateContentState: ->
|
||||
@state.content.scrollWidth = @computeScrollWidth()
|
||||
@state.content.indentGuidesVisible = atom.config.get('editor.showIndentGuide')
|
||||
|
||||
updateLinesState: ->
|
||||
visibleLineIds = {}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário