Revert softWrapAtNewline attempt

...now we use `skipSoftWrapIndentation: true` when moving up and down.
This commit is contained in:
Antonio Scandurra 2015-02-20 09:46:39 +01:00
parent ed77358515
commit ab5c79d009
4 changed files with 20 additions and 17 deletions

View File

@ -615,6 +615,18 @@ describe "DisplayBuffer", ->
displayBuffer.createFold(3, 5)
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", ->
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", ->
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]
describe "when wrapAtSoftNewlines is false (the default)", ->
it "clips positions at the end of soft-wrapped lines to the character preceding the end of the line", ->
expect(displayBuffer.clipScreenPosition([3, 50])).toEqual [3, 50]
@ -622,11 +634,6 @@ describe "DisplayBuffer", ->
expect(displayBuffer.clipScreenPosition([3, 58])).toEqual [3, 50]
expect(displayBuffer.clipScreenPosition([3, 1000])).toEqual [3, 50]
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 wrapAtSoftNewlines is true", ->
it "wraps positions at the end of soft-wrapped lines to the next screen line", ->
expect(displayBuffer.clipScreenPosition([3, 50], wrapAtSoftNewlines: true)).toEqual [3, 50]
@ -634,11 +641,6 @@ describe "DisplayBuffer", ->
expect(displayBuffer.clipScreenPosition([3, 58], wrapAtSoftNewlines: true)).toEqual [4, 4]
expect(displayBuffer.clipScreenPosition([3, 1000], wrapAtSoftNewlines: true)).toEqual [4, 4]
it "clips positions to the beginning of the line", ->
expect(displayBuffer.clipScreenPosition([4, 0], wrapAtSoftNewlines: true)).toEqual [4, 4]
expect(displayBuffer.clipScreenPosition([4, 1], wrapAtSoftNewlines: true)).toEqual [4, 4]
expect(displayBuffer.clipScreenPosition([4, 3], wrapAtSoftNewlines: true)).toEqual [4, 4]
describe "when skipAtomicTokens is false (the default)", ->
it "clips screen positions in the middle of atomic tab characters to the beginning of the character", ->
buffer.insert([0, 0], '\t')

View File

@ -670,8 +670,8 @@ describe "TokenizedBuffer", ->
[segment1, segment2] = tokenizedLine.softWrapAt(16)
expect(segment1.tokens[5].value).toBe ' '
expect(segment1.tokens[5].firstTrailingWhitespaceIndex).toBe null
expect(segment2.tokens[7].value).toBe ' '
expect(segment2.tokens[7].firstTrailingWhitespaceIndex).toBe 0
expect(segment2.tokens[6].value).toBe ' '
expect(segment2.tokens[6].firstTrailingWhitespaceIndex).toBe 0
it "sets leading and trailing whitespace correctly on a line with invisible characters that is copied", ->
buffer.setText(" \t a line with tabs\tand \tspaces \t ")

View File

@ -271,7 +271,7 @@ class Cursor extends Model
{ row, column } = @getScreenPosition()
column = @goalColumn if @goalColumn?
@setScreenPosition({row: row - rowCount, column: column}, wrapAtSoftNewlines: true)
@setScreenPosition({row: row - rowCount, column: column}, skipSoftWrapIndentation: true)
@goalColumn = column
# Public: Moves the cursor down one screen row.
@ -288,7 +288,7 @@ class Cursor extends Model
{ row, column } = @getScreenPosition()
column = @goalColumn if @goalColumn?
@setScreenPosition({row: row + rowCount, column: column}, wrapAtSoftNewlines: true)
@setScreenPosition({row: row + rowCount, column: column}, skipSoftWrapIndentation: true)
@goalColumn = column
# Public: Moves the cursor left one screen column.
@ -359,7 +359,7 @@ class Cursor extends Model
# line.
moveToFirstCharacterOfLine: ->
screenRow = @getScreenRow()
screenLineStart = @editor.clipScreenPosition([screenRow, 0], wrapAtSoftNewlines: true)
screenLineStart = @editor.clipScreenPosition([screenRow, 0], skipSoftWrapIndentation: true)
screenLineEnd = [screenRow, Infinity]
screenLineBufferRange = @editor.bufferRangeForScreenRange([screenLineStart, screenLineEnd])

View File

@ -819,11 +819,12 @@ 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
# 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.
clipScreenPosition: (screenPosition, options={}) ->
{ wrapBeyondNewlines, wrapAtSoftNewlines } = options
{ wrapBeyondNewlines, wrapAtSoftNewlines, skipSoftWrapIndentation } = options
{ row, column } = Point.fromObject(screenPosition)
if row < 0
@ -845,7 +846,7 @@ class DisplayBuffer extends Model
else
column = screenLine.clipScreenColumn(maxScreenColumn - 1)
else if screenLine.isColumnInsideSoftWrapIndentation(column)
if wrapAtSoftNewlines
if skipSoftWrapIndentation
column = screenLine.clipScreenColumn(0)
else
row--