diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 368db26d4..e4c522df1 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -344,11 +344,29 @@ describe "EditorComponent", -> expect(line13LeafNodes[1].textContent).toBe ' ' expect(line13LeafNodes[1].classList.contains('indent-guide')).toBe true - getLeafNodes = (node) -> - if node.children.length > 0 - flatten(toArray(node.children).map(getLeafNodes)) - else - [node] + describe "when indent guides are disabled", -> + beforeEach -> + component.setShowIndentGuide(false) + runSetImmediateCallbacks() + + it "does not render indent guides on lines containing only whitespace", -> + editor.getBuffer().insert([1, Infinity], '\n ') + runSetImmediateCallbacks() + + line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2)) + expect(line2LeafNodes.length).toBe 3 + expect(line2LeafNodes[0].textContent).toBe ' ' + expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe false + expect(line2LeafNodes[1].textContent).toBe ' ' + expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe false + expect(line2LeafNodes[2].textContent).toBe ' ' + expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe false + + getLeafNodes = (node) -> + if node.children.length > 0 + flatten(toArray(node.children).map(getLeafNodes)) + else + [node] describe "when the buffer contains null bytes", -> it "excludes the null byte from character measurement", -> diff --git a/src/lines-component.coffee b/src/lines-component.coffee index f73d7d2b2..1e5db6407 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -189,7 +189,7 @@ LinesComponent = React.createClass lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0 for token in tokens innerHTML += @updateScopeStack(scopeStack, token.scopes) - hasIndentGuide = not mini and showIndentGuide and token.hasLeadingWhitespace or (token.hasTrailingWhitespace and lineIsWhitespaceOnly) + hasIndentGuide = not mini and showIndentGuide and (token.hasLeadingWhitespace or (token.hasTrailingWhitespace and lineIsWhitespaceOnly)) innerHTML += token.getValueAsHtml({invisibles, hasIndentGuide}) innerHTML += @popScope(scopeStack) while scopeStack.length > 0