Use softWrapIndentation name consistently

This commit is contained in:
Antonio Scandurra 2015-02-20 10:11:47 +01:00
parent ab5c79d009
commit 0258531a3c
4 changed files with 23 additions and 23 deletions

View File

@ -116,9 +116,9 @@ describe "DisplayBuffer", ->
expect(displayBuffer.tokenizedLineForScreenRow(3).tokens[1].isHardTab).toBeTruthy()
describe "when a line is wrapped", ->
it "correctly tokenizes soft wrap indent tokens", ->
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[0].isSoftWrapIndent).toBeTruthy()
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[1].isSoftWrapIndent).toBeTruthy()
it "correctly tokenizes soft wrap indentation tokens", ->
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[0].isSoftWrapIndentation).toBeTruthy()
expect(displayBuffer.tokenizedLineForScreenRow(4).tokens[1].isSoftWrapIndentation).toBeTruthy()
describe "when the buffer changes", ->
describe "when buffer lines are updated", ->
@ -616,13 +616,13 @@ describe "DisplayBuffer", ->
expect(displayBuffer.clipScreenPosition([3, 5], wrapBeyondNewlines: true)).toEqual [4, 0]
describe "when skipSoftWrapIndentation is false (the default)", ->
it "clips positions to the beginning of the line", ->
it "wraps positions at the end of previous soft-wrapped line", ->
expect(displayBuffer.clipScreenPosition([4, 0])).toEqual [3, 50]
expect(displayBuffer.clipScreenPosition([4, 1])).toEqual [3, 50]
expect(displayBuffer.clipScreenPosition([4, 3])).toEqual [3, 50]
describe "when skipSoftWrapIndentation is true", ->
it "wraps positions at the end of previous soft-wrapped line", ->
it "clips positions to the beginning of the line", ->
expect(displayBuffer.clipScreenPosition([4, 0], skipSoftWrapIndentation: true)).toEqual [4, 4]
expect(displayBuffer.clipScreenPosition([4, 1], skipSoftWrapIndentation: true)).toEqual [4, 4]
expect(displayBuffer.clipScreenPosition([4, 3], skipSoftWrapIndentation: true)).toEqual [4, 4]

View File

@ -819,7 +819,7 @@ class DisplayBuffer extends Model
# options - A hash with the following values:
# wrapBeyondNewlines: if `true`, continues wrapping past newlines
# wrapAtSoftNewlines: if `true`, continues wrapping past soft newlines
# skipSoftWrapIndentation: if `true`, skips soft wrap indentation
# skipSoftWrapIndentation: if `true`, skips soft wrap indentation without wrapping to the previous line
# screenLine: if `true`, indicates that you're using a line number, not a row number
#
# Returns the new, clipped {Point}. Note that this could be the same as `position` if no clipping was performed.

View File

@ -21,7 +21,7 @@ class Token
firstTrailingWhitespaceIndex: null
hasInvisibleCharacters: false
constructor: ({@value, @scopes, @isAtomic, @bufferDelta, @isHardTab, @hasPairedCharacter, @isSoftWrapIndent}) ->
constructor: ({@value, @scopes, @isAtomic, @bufferDelta, @isHardTab, @hasPairedCharacter, @isSoftWrapIndentation}) ->
@screenDelta = @value.length
@bufferDelta ?= @screenDelta
@hasPairedCharacter ?= textUtils.hasPairedCharacter(@value)
@ -144,13 +144,13 @@ class Token
isHardTab: isHardTab
)
buildSoftWrapIndentToken: (length) ->
buildSoftWrapIndentationToken: (length) ->
new Token(
value: _.multiplyString(" ", length),
scopes: @scopes,
bufferDelta: 0,
isAtomic: true,
isSoftWrapIndent: true
isSoftWrapIndentation: true
)
isOnlyWhitespace: ->

View File

@ -17,8 +17,8 @@ class TokenizedLine
@tokens = @breakOutAtomicTokens(tokens)
@text = @buildText()
@bufferDelta = @buildBufferDelta()
@softWrapIndentTokens = @getSoftWrapIndentTokens()
@softWrapIndentDelta = @buildSoftWrapIndentDelta()
@softWrapIndentationTokens = @getSoftWrapIndentationTokens()
@softWrapIndentationDelta = @buildSoftWrapIndentationDelta()
@id = idCounter++
@markLeadingAndTrailingWhitespaceTokens()
@ -51,7 +51,7 @@ class TokenizedLine
tokenStartColumn += token.screenDelta
if @isColumnInsideSoftWrapIndentation(tokenStartColumn)
@softWrapIndentDelta
@softWrapIndentationDelta
else if token.isAtomic and tokenStartColumn < column
if skipAtomicTokens
tokenStartColumn + token.screenDelta
@ -124,7 +124,7 @@ class TokenizedLine
leftTokens.push nextToken
indentTokens = [0...@indentLevel].map =>
leftTokens[0].buildSoftWrapIndentToken(@tabLength)
leftTokens[0].buildSoftWrapIndentationToken(@tabLength)
leftFragment = new TokenizedLine(
tokens: leftTokens
@ -150,23 +150,23 @@ class TokenizedLine
@lineEnding is null
isColumnOutsideSoftWrapIndentation: (column) ->
return true if @softWrapIndentTokens.length == 0
return true if @softWrapIndentationTokens.length == 0
column > @softWrapIndentDelta
column > @softWrapIndentationDelta
isColumnInsideSoftWrapIndentation: (column) ->
return false if @softWrapIndentTokens.length == 0
return false if @softWrapIndentationTokens.length == 0
column < @softWrapIndentDelta
column < @softWrapIndentationDelta
getSoftWrapIndentTokens: ->
_.select(@tokens, (token) -> token.isSoftWrapIndent)
getSoftWrapIndentationTokens: ->
_.select(@tokens, (token) -> token.isSoftWrapIndentation)
buildSoftWrapIndentDelta: ->
_.reduce @softWrapIndentTokens, ((acc, token) -> acc + token.screenDelta), 0
buildSoftWrapIndentationDelta: ->
_.reduce @softWrapIndentationTokens, ((acc, token) -> acc + token.screenDelta), 0
hasOnlySoftWrapIndentation: ->
@tokens.length == @softWrapIndentTokens.length
@tokens.length == @softWrapIndentationTokens.length
tokenAtBufferColumn: (bufferColumn) ->
@tokens[@tokenIndexAtBufferColumn(bufferColumn)]
@ -222,7 +222,7 @@ class TokenizedLine
changedText = true
else
if invisibles.space
if token.hasLeadingWhitespace() and not token.isSoftWrapIndent
if token.hasLeadingWhitespace() and not token.isSoftWrapIndentation
token.value = token.value.replace LeadingWhitespaceRegex, (leadingWhitespace) ->
leadingWhitespace.replace RepeatedSpaceRegex, invisibles.space
token.hasInvisibleCharacters = true