From f5fa3b837e2b6f60297b486d61afb160aaa0f4e1 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 27 Jan 2015 14:34:53 -0700 Subject: [PATCH] Set content.indentGuidesVisible in presenter if editor is mini --- spec/text-editor-presenter-spec.coffee | 10 ++++++++++ src/lines-component.coffee | 2 +- src/text-editor-presenter.coffee | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index e766037b0..a4853efe2 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -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)') diff --git a/src/lines-component.coffee b/src/lines-component.coffee index d3ccf4bc8..242c69a8a 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -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 diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index fe1f6e4a2..c7b8cfba7 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -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'