mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Show indent guides on hanging indentation too
This commit is contained in:
@@ -140,6 +140,7 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[0].isSoftWrapIndentation).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[1].isSoftWrapIndentation).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[2].isSoftWrapIndentation).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[3].isSoftWrapIndentation).toBeTruthy()
|
||||
|
||||
describe "when the buffer changes", ->
|
||||
describe "when buffer lines are updated", ->
|
||||
|
||||
@@ -111,28 +111,26 @@ class TokenizedLine
|
||||
|
||||
return maxColumn
|
||||
|
||||
# Calculates how many trailing spaces in this line's indentation cannot fit in a single tab.
|
||||
# For a given `indentLevel`, calculates how many trailing spaces cannot fit in a single tab.
|
||||
#
|
||||
# Returns a {Number} representing the odd indentation spaces in this line.
|
||||
getOddIndentationSpaces: ->
|
||||
oddIndentLevel = @indentLevel - Math.floor(@indentLevel)
|
||||
# indentLevel - {Number}
|
||||
# Returns a {Number} representing the odd indentation spaces for `indentLevel`.
|
||||
oddIndentationSpacesForIndentLevel: (indentLevel) ->
|
||||
oddIndentLevel = indentLevel - Math.floor(indentLevel)
|
||||
Math.round(@tabLength * oddIndentLevel)
|
||||
|
||||
buildSoftWrapIndentationTokens: (token, hangingIndentationSpaces) ->
|
||||
indentTokens = [0...Math.floor(@indentLevel)].map =>
|
||||
hangingIndentLevel = hangingIndentationSpaces / @tabLength
|
||||
indentLevel = @indentLevel + hangingIndentLevel
|
||||
indentTokens = [0...Math.floor(indentLevel)].map =>
|
||||
token.buildSoftWrapIndentationToken(@tabLength)
|
||||
|
||||
if @getOddIndentationSpaces()
|
||||
indentTokens.push(
|
||||
token.buildSoftWrapIndentationToken(@getOddIndentationSpaces())
|
||||
if oddIndentationSpaces = @oddIndentationSpacesForIndentLevel(indentLevel)
|
||||
indentTokens.concat(
|
||||
token.buildSoftWrapIndentationToken(oddIndentationSpaces)
|
||||
)
|
||||
|
||||
if hangingIndentationSpaces
|
||||
indentTokens.push(
|
||||
token.buildSoftWrapIndentationToken(hangingIndentationSpaces)
|
||||
)
|
||||
|
||||
indentTokens
|
||||
else
|
||||
indentTokens
|
||||
|
||||
softWrapAt: (column, options = {}) ->
|
||||
return [new TokenizedLine([], '', [0, 0], [0, 0]), this] if column == 0
|
||||
|
||||
Reference in New Issue
Block a user