Set content.indentGuidesVisible in presenter if editor is mini

This commit is contained in:
Nathan Sobo
2015-01-27 14:34:53 -07:00
parent b21b9c3402
commit f5fa3b837e
3 changed files with 12 additions and 2 deletions

View File

@@ -167,6 +167,16 @@ describe "TextEditorPresenter", ->
expectStateUpdate presenter, -> editor.setGrammar(atom.grammars.selectGrammar('.txt'))
expect(presenter.state.content.indentGuidesVisible).toBe false
it "is always false when the editor is mini", ->
atom.config.set('editor.showIndentGuide', true)
editor.setMini(true)
presenter = new TextEditorPresenter(model: editor)
expect(presenter.state.content.indentGuidesVisible).toBe false
editor.setMini(false)
expect(presenter.state.content.indentGuidesVisible).toBe true
editor.setMini(true)
expect(presenter.state.content.indentGuidesVisible).toBe false
describe ".backgroundColor", ->
it "is assigned to ::backgroundColor unless the editor is mini", ->
presenter = new TextEditorPresenter(model: editor, backgroundColor: 'rgba(255, 0, 0, 0)')

View File

@@ -184,7 +184,7 @@ LinesComponent = React.createClass
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
for token in tokens
innerHTML += @updateScopeStack(scopeStack, token.scopes)
hasIndentGuide = not editor.isMini() and indentGuidesVisible and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and lineIsWhitespaceOnly))
hasIndentGuide = indentGuidesVisible and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and lineIsWhitespaceOnly))
innerHTML += token.getValueAsHtml({hasIndentGuide})
innerHTML += @popScope(scopeStack) while scopeStack.length > 0

View File

@@ -74,7 +74,7 @@ class TextEditorPresenter
updateContentState: ->
@state.content.scrollWidth = @computeScrollWidth()
@state.content.scrollLeft = @getScrollLeft()
@state.content.indentGuidesVisible = atom.config.get('editor.showIndentGuide', scope: @model.getRootScopeDescriptor())
@state.content.indentGuidesVisible = not @model.isMini() and atom.config.get('editor.showIndentGuide', scope: @model.getRootScopeDescriptor())
@state.content.backgroundColor = if @model.isMini() then null else @getBackgroundColor()
@emitter.emit 'did-update-state'