diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 0a9ecc7c2..7f373b547 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -102,6 +102,15 @@ describe "EditorComponent", -> expect(line2LeafNodes[2].textContent).toBe ' ' expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe true + it "does not render indent guides in trailing whitespace for lines containing non whitespace characters", -> + editor.getBuffer().setText (" hi ") + lines = node.querySelectorAll('.line') + line0LeafNodes = getLeafNodes(lines[0]) + expect(line0LeafNodes[0].textContent).toBe ' ' + expect(line0LeafNodes[0].classList.contains('indent-guide')).toBe true + expect(line0LeafNodes[1].textContent).toBe ' ' + expect(line0LeafNodes[1].classList.contains('indent-guide')).toBe false + 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..5f1baab1d 100644 --- a/src/token.coffee +++ b/src/token.coffee @@ -155,8 +155,9 @@ class Token startIndex = match[0].length if @hasTrailingWhitespace and match = TrailingWhitespaceRegex.exec(@value) + tokenIsOnlyWhitespace = match[0].length is @value.length classes = 'trailing-whitespace' - classes += ' indent-guide' if hasIndentGuide and not @hasLeadingWhitespace + classes += ' indent-guide' if hasIndentGuide and not @hasLeadingWhitespace and tokenIsOnlyWhitespace classes += ' invisible-character' if invisibles.space match[0] = match[0].replace(CharacterRegex, invisibles.space) if invisibles.space