mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Get rid of wrapAtPhantomTokens
This commit is contained in:
@@ -599,18 +599,6 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.clipScreenPosition([1000, 0])).toEqual [15, 2]
|
||||
expect(displayBuffer.clipScreenPosition([1000, 1000])).toEqual [15, 2]
|
||||
|
||||
describe "when wrapAtPhantomTokens is false (the default)", ->
|
||||
it "clips positions inside a phantom token to the beginning of the line", ->
|
||||
expect(displayBuffer.clipScreenPosition([4, 0])).toEqual [4, 4]
|
||||
expect(displayBuffer.clipScreenPosition([4, 1])).toEqual [4, 4]
|
||||
expect(displayBuffer.clipScreenPosition([4, 3])).toEqual [4, 4]
|
||||
|
||||
describe "when wrapAtPhantomTokens is true", ->
|
||||
it "wraps positions inside a phantom token to the previous line", ->
|
||||
expect(displayBuffer.clipScreenPosition([4, 0], wrapAtPhantomTokens: true)).toEqual [3, 51]
|
||||
expect(displayBuffer.clipScreenPosition([4, 1], wrapAtPhantomTokens: true)).toEqual [3, 51]
|
||||
expect(displayBuffer.clipScreenPosition([4, 3], wrapAtPhantomTokens: true)).toEqual [3, 51]
|
||||
|
||||
describe "when wrapBeyondNewlines is false (the default)", ->
|
||||
it "wraps positions beyond the end of hard newlines to the end of the line", ->
|
||||
expect(displayBuffer.clipScreenPosition([1, 10000])).toEqual [1, 30]
|
||||
@@ -634,6 +622,11 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.clipScreenPosition([3, 58])).toEqual [3, 50]
|
||||
expect(displayBuffer.clipScreenPosition([3, 1000])).toEqual [3, 50]
|
||||
|
||||
it "clips positions inside a phantom token to the beginning of the line", ->
|
||||
expect(displayBuffer.clipScreenPosition([4, 0])).toEqual [4, 4]
|
||||
expect(displayBuffer.clipScreenPosition([4, 1])).toEqual [4, 4]
|
||||
expect(displayBuffer.clipScreenPosition([4, 3])).toEqual [4, 4]
|
||||
|
||||
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]
|
||||
@@ -641,6 +634,11 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.clipScreenPosition([3, 58], wrapAtSoftNewlines: true)).toEqual [4, 4]
|
||||
expect(displayBuffer.clipScreenPosition([3, 1000], wrapAtSoftNewlines: true)).toEqual [4, 4]
|
||||
|
||||
it "wraps positions inside a phantom token to the previous line", ->
|
||||
expect(displayBuffer.clipScreenPosition([4, 0], wrapAtSoftNewlines: true)).toEqual [3, 50]
|
||||
expect(displayBuffer.clipScreenPosition([4, 1], wrapAtSoftNewlines: true)).toEqual [3, 50]
|
||||
expect(displayBuffer.clipScreenPosition([4, 3], wrapAtSoftNewlines: true)).toEqual [3, 50]
|
||||
|
||||
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')
|
||||
|
||||
@@ -304,13 +304,14 @@ class Cursor extends Model
|
||||
else
|
||||
{row, column} = @getScreenPosition()
|
||||
|
||||
originalRow = row
|
||||
while columnCount > column and row > 0
|
||||
columnCount -= column
|
||||
column = @editor.lineTextForScreenRow(--row).length
|
||||
columnCount-- # subtract 1 for the row move
|
||||
|
||||
column = column - columnCount
|
||||
@setScreenPosition({row, column}, wrapAtPhantomTokens: true)
|
||||
@setScreenPosition({row, column}, wrapAtSoftNewlines: originalRow == row)
|
||||
|
||||
# Public: Moves the cursor right one screen column.
|
||||
#
|
||||
|
||||
@@ -819,12 +819,11 @@ 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
|
||||
# wrapAtPhantomTokens: if `true`, continues wrapping before phantom tokens
|
||||
# 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, wrapAtPhantomTokens } = options
|
||||
{ wrapBeyondNewlines, wrapAtSoftNewlines } = options
|
||||
{ row, column } = Point.fromObject(screenPosition)
|
||||
|
||||
if row < 0
|
||||
@@ -846,9 +845,9 @@ class DisplayBuffer extends Model
|
||||
else
|
||||
column = screenLine.clipScreenColumn(maxScreenColumn - 1)
|
||||
else if screenLine.isColumnInsidePhantomToken(column)
|
||||
if wrapAtPhantomTokens
|
||||
if wrapAtSoftNewlines
|
||||
row--
|
||||
column = @screenLines[row].getMaxScreenColumn()
|
||||
column = @screenLines[row].getMaxScreenColumn() - 1
|
||||
else
|
||||
column = screenLine.clipScreenColumn(0)
|
||||
else if wrapBeyondNewlines and column > maxScreenColumn and row < @getLastRow()
|
||||
|
||||
Reference in New Issue
Block a user