diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 09d280b69..402a14f50 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -82,6 +82,18 @@ describe "EditorComponent", -> expect(line2LeafNodes[2].textContent).toBe ' ' expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe true + it "renders indent guides correctly on lines containing only whitespace", -> + editor.getBuffer().insert([1, Infinity], '\n ') + lines = node.querySelectorAll('.line') + line2LeafNodes = getLeafNodes(lines[2]) + expect(line2LeafNodes.length).toBe 3 + expect(line2LeafNodes[0].textContent).toBe ' ' + expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe true + expect(line2LeafNodes[1].textContent).toBe ' ' + expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe true + expect(line2LeafNodes[2].textContent).toBe ' ' + expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe true + getLeafNodes = (node) -> if node.children.length > 0 flatten(toArray(node.children).map(getLeafNodes)) diff --git a/src/token.coffee b/src/token.coffee index f42c5a9cc..aabd60bdb 100644 --- a/src/token.coffee +++ b/src/token.coffee @@ -144,7 +144,7 @@ class Token leadingHtml = '' trailingHtml = '' - if @hasLeadingWhitespace and match = LeadingWhitespaceRegex.exec(@value) + if @hasLeadingWhitespace and not @hasTrailingWhitespace and match = LeadingWhitespaceRegex.exec(@value) classes = 'leading-whitespace' classes += ' indent-guide' if hasIndentGuide classes += ' invisible-character' if invisibles.space @@ -156,7 +156,7 @@ class Token if @hasTrailingWhitespace and match = TrailingWhitespaceRegex.exec(@value) classes = 'trailing-whitespace' - classes += ' indent-guide' if hasIndentGuide and not @hasLeadingWhitespace + classes += ' indent-guide' if hasIndentGuide and @hasLeadingWhitespace classes += ' invisible-character' if invisibles.space match[0] = match[0].replace(CharacterRegex, invisibles.space) if invisibles.space