mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Add indent guide to whitespace lines
The whitespace in lines that have no non-whitespace text is treated as trailing whitespace so add the indent guide to the trailing whitespace tokens when the line is 100% whitespace.
This commit is contained in:
@@ -1201,16 +1201,14 @@ class Editor extends View
|
||||
else
|
||||
firstNonWhitespacePosition = screenLine.text.search(/\S/)
|
||||
firstTrailingWhitespacePosition = screenLine.text.search(/\s*$/)
|
||||
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
|
||||
position = 0
|
||||
for token in screenLine.tokens
|
||||
updateScopeStack(token.scopes)
|
||||
line.push(token.getValueAsHtml(
|
||||
invisibles: invisibles
|
||||
hasLeadingWhitespace: position < firstNonWhitespacePosition
|
||||
hasTrailingWhitespace: position + token.value.length > firstTrailingWhitespacePosition
|
||||
hasIndentGuide: @showIndentGuide
|
||||
))
|
||||
|
||||
hasLeadingWhitespace = position < firstNonWhitespacePosition
|
||||
hasTrailingWhitespace = position + token.value.length > firstTrailingWhitespacePosition
|
||||
hasIndentGuide = @showIndentGuide and (hasLeadingWhitespace or lineIsWhitespaceOnly)
|
||||
line.push(token.getValueAsHtml({invisibles, hasLeadingWhitespace, hasTrailingWhitespace, hasIndentGuide}))
|
||||
position += token.value.length
|
||||
|
||||
popScope() while scopeStack.length > 0
|
||||
|
||||
@@ -92,6 +92,7 @@ class Token
|
||||
html = html.replace /[ ]+$/, (match) ->
|
||||
classes = []
|
||||
classes.push('invisible') if invisibles.space
|
||||
classes.push('indent-guide') if hasIndentGuide
|
||||
classes.push('trailing-whitespace')
|
||||
match = match.replace(/./g, invisibles.space) if invisibles.space
|
||||
"<span class='#{classes.join(' ')}'>#{match}</span>"
|
||||
|
||||
Reference in New Issue
Block a user