Treat all whitespace lines as not having leading whitespace

Instead it's treated as all trailing whitespace, as it was originally.
This commit is contained in:
Nathan Sobo
2014-04-11 09:11:49 -06:00
parent e3eb51c135
commit 28dd7d4acd
3 changed files with 5 additions and 5 deletions

View File

@@ -483,9 +483,9 @@ describe "TokenizedBuffer", ->
expect(tokenizedBuffer.lineForScreenRow(5).tokens[3].hasLeadingWhitespace).toBe true
expect(tokenizedBuffer.lineForScreenRow(5).tokens[4].hasLeadingWhitespace).toBe false
# Lines that are *only* whitespace are considered to have leading whitespace
# Lines that are *only* whitespace are not considered to have leading whitespace
buffer.insert([10, 0], ' ')
expect(tokenizedBuffer.lineForScreenRow(10).tokens[0].hasLeadingWhitespace).toBe true
expect(tokenizedBuffer.lineForScreenRow(10).tokens[0].hasLeadingWhitespace).toBe false
it "sets ::hasTrailingWhitespace to true on tokens that have trailing whitespace", ->
buffer.insert([0, Infinity], ' ')

View File

@@ -144,7 +144,7 @@ class Token
leadingHtml = ''
trailingHtml = ''
if @hasLeadingWhitespace and not @hasTrailingWhitespace and match = LeadingWhitespaceRegex.exec(@value)
if @hasLeadingWhitespace 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 @hasLeadingWhitespace
classes += ' indent-guide' if hasIndentGuide and not @hasLeadingWhitespace
classes += ' invisible-character' if invisibles.space
match[0] = match[0].replace(CharacterRegex, invisibles.space) if invisibles.space

View File

@@ -119,7 +119,7 @@ class TokenizedLine
outputTokens
markLeadingAndTrailingWhitespaceTokens: ->
firstNonWhitespacePosition = @text.search(/\S|$/)
firstNonWhitespacePosition = @text.search(/\S/)
firstTrailingWhitespacePosition = @text.search(/\s*$/)
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
position = 0