mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Only mark trailing whitespace on the last segment of a soft-wrapped line
This commit is contained in:
committed by
Nathan Sobo
parent
b4af0a79d0
commit
5e38add177
@@ -500,3 +500,12 @@ describe "TokenizedBuffer", ->
|
||||
# Lines that are *only* whitespace are considered to have trailing whitespace
|
||||
buffer.insert([10, 0], ' ')
|
||||
expect(tokenizedBuffer.lineForScreenRow(10).tokens[0].hasTrailingWhitespace).toBe true
|
||||
|
||||
it "only marks trailing whitespace on the last segment of a soft-wrapped line", ->
|
||||
buffer.insert([0, Infinity], ' ')
|
||||
tokenizedLine = tokenizedBuffer.lineForScreenRow(0)
|
||||
[segment1, segment2] = tokenizedLine.softWrapAt(16)
|
||||
expect(segment1.tokens[5].value).toBe ' '
|
||||
expect(segment1.tokens[5].hasTrailingWhitespace).toBe false
|
||||
expect(segment2.tokens[6].value).toBe ' '
|
||||
expect(segment2.tokens[6].hasTrailingWhitespace).toBe true
|
||||
|
||||
@@ -125,7 +125,8 @@ class TokenizedLine
|
||||
position = 0
|
||||
for token, i in @tokens
|
||||
token.hasLeadingWhitespace = position < firstNonWhitespacePosition
|
||||
token.hasTrailingWhitespace = position + token.value.length > firstTrailingWhitespacePosition
|
||||
# Only the *last* segment of a soft-wrapped line can have trailing whitespace
|
||||
token.hasTrailingWhitespace = @lineEnding? and (position + token.value.length > firstTrailingWhitespacePosition)
|
||||
position += token.value.length
|
||||
|
||||
isComment: ->
|
||||
|
||||
Reference in New Issue
Block a user