From 0258531a3c727aeb7ae3033d51442d84f1fa1ac9 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 20 Feb 2015 10:11:47 +0100 Subject: [PATCH] Use softWrapIndentation name consistently --- spec/display-buffer-spec.coffee | 10 +++++----- src/display-buffer.coffee | 2 +- src/token.coffee | 6 +++--- src/tokenized-line.coffee | 28 ++++++++++++++-------------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index aaf2c68ed..38cf3acc9 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -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] diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 8c5bd430e..7e08d3998 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -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. diff --git a/src/token.coffee b/src/token.coffee index a088acac7..778ea16e6 100644 --- a/src/token.coffee +++ b/src/token.coffee @@ -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: -> diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index d9a45241e..50d3356de 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -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