Don't show indent guide in truly trailing whitespace

Lines that are all whitespace are considered trailing
whitespace and should display the indent guide.

But lines with leading and trailing whitespace should never
have the indent guide rendered in the trailing area.
This commit is contained in:
Kevin Sawicki 2013-05-02 11:42:12 -07:00
parent 67f96e0fdd
commit 10ca03f238
2 changed files with 10 additions and 1 deletions

View File

@ -1551,6 +1551,15 @@ describe "Editor", ->
expect(editor.renderedLines.find('.line:eq(10) .indent-guide').length).toBe 2
expect(editor.renderedLines.find('.line:eq(10) .indent-guide').text()).toBe ' '
describe "when the line has leading and trailing whitespace", ->
it "does not display the indent guide in the trailing whitespace", ->
editor.attachToDom()
config.set("editor.showIndentGuide", true)
editor.insertText("/*\n * \n*/")
expect(editor.renderedLines.find('.line:eq(1) .indent-guide').length).toBe 1
expect(editor.renderedLines.find('.line:eq(1) .indent-guide')).toHaveClass('leading-whitespace')
describe "when the line is empty and end of show invisibles are enabled", ->
it "renders the indent guides interleaved the end of line invisibles", ->
editor.attachToDom()

View File

@ -92,7 +92,7 @@ class Token
"<span class='#{classes}'>#{match}</span>"
if hasTrailingWhitespace
classes = []
classes.push('indent-guide') if hasIndentGuide
classes.push('indent-guide') if hasIndentGuide and not hasLeadingWhitespace
classes.push('invisible-character') if invisibles.space
classes.push('trailing-whitespace')
classes = classes.join(' ')