From ae9f79bfc4cf796f7498bfde25cc490e29b91e13 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 16 Apr 2014 12:37:35 -0600 Subject: [PATCH] Only add indent guide to trailing whitespace on whitespace-only lines --- spec/editor-component-spec.coffee | 9 +++++++++ src/token.coffee | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) 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