Add leading/trailing classes to hard tab tokens

Previously the leading-whitespace and trailing-whitespace classes
were never added to tokens that were hard tabs.
This commit is contained in:
Kevin Sawicki 2014-09-16 17:42:34 -07:00
parent 72b92fc3e5
commit b281737838
2 changed files with 28 additions and 0 deletions

View File

@ -197,6 +197,32 @@ describe "EditorComponent", ->
nextAnimationFrame()
expect(linesNode.style.backgroundColor).toBe 'rgb(255, 0, 0)'
it "applies .trailing-whitespace for lines with trailing spaces and/or tabs", ->
editor.setText('a ')
nextAnimationFrame()
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe true
editor.setText('a\t')
nextAnimationFrame()
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
expect(leafNodes[0].classList.contains('trailing-whitespace')).toBe true
it "applies .leading-whitespace for lines with trailing spaces and/or tabs", ->
editor.setText(' a')
nextAnimationFrame()
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe true
editor.setText('\ta')
nextAnimationFrame()
leafNodes = getLeafNodes(component.lineNodeForScreenRow(0))
expect(leafNodes[0].classList.contains('leading-whitespace')).toBe true
describe "when showInvisibles is enabled", ->
invisibles = null

View File

@ -153,6 +153,8 @@ class Token
getValueAsHtml: ({hasIndentGuide}) ->
if @isHardTab
classes = 'hard-tab'
classes += ' leading-whitespace' if @hasLeadingWhitespace()
classes += ' trailing-whitespace' if @hasTrailingWhitespace()
classes += ' indent-guide' if hasIndentGuide
classes += ' invisible-character' if @hasInvisibleCharacters
html = "<span class='#{classes}'>#{@escapeString(@value)}</span>"