mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
LineMap.spliceScreenRow can replace multiple fragments at row 0
Subtle bug where the falsiness of 0 was causing line fragments on the 0th row to be skipped
This commit is contained in:
@@ -42,14 +42,16 @@ describe "LineMap", ->
|
||||
describe ".spliceAtBufferRow(bufferRow, rowCount, screenLines)", ->
|
||||
describe "when called with a row count of 0", ->
|
||||
it "inserts the given line fragments before the specified buffer row", ->
|
||||
map.insertAtBufferRow(0, [line0, line1, line2])
|
||||
map.insertAtBufferRow(0, [line0, line1])
|
||||
map.spliceAtBufferRow(1, 0, [line3, line4])
|
||||
|
||||
expect(map.lineForScreenRow(0)).toEqual line0
|
||||
expect(map.lineForScreenRow(1)).toEqual line3
|
||||
expect(map.lineForScreenRow(2)).toEqual line4
|
||||
expect(map.lineForScreenRow(3)).toEqual line1
|
||||
expect(map.lineForScreenRow(4)).toEqual line2
|
||||
|
||||
map.spliceAtBufferRow(0, 0, [line2])
|
||||
expect(map.lineForScreenRow(0)).toEqual line2
|
||||
|
||||
describe "when called with a row count of 1", ->
|
||||
describe "when the specified buffer row is spanned by a single line fragment", ->
|
||||
@@ -116,18 +118,19 @@ describe "LineMap", ->
|
||||
|
||||
describe "when the specified screen row is spanned by multiple line fragments", ->
|
||||
it "replaces all spanning line fragments with the given line fragments", ->
|
||||
[line1a, line1b] = line1.splitAt(10)
|
||||
[line0a, line0b] = line0.splitAt(10)
|
||||
[line3a, line3b] = line3.splitAt(10)
|
||||
|
||||
map.insertAtBufferRow(0, [line0, line1a, line1b, line2])
|
||||
map.spliceAtScreenRow(1, 1, [line3a, line3b, line4])
|
||||
map.insertAtBufferRow(0, [line0a, line0b, line1, line2])
|
||||
map.spliceAtScreenRow(0, 1, [line3a, line3b, line4])
|
||||
|
||||
expect(map.bufferLineCount()).toBe 4
|
||||
expect(map.lineForScreenRow(0)).toEqual line0
|
||||
expect(map.lineForScreenRow(1)).toEqual line3a.concat(line3b)
|
||||
expect(map.lineForScreenRow(2)).toEqual line4
|
||||
expect(map.lineForScreenRow(0)).toEqual line3a.concat(line3b)
|
||||
expect(map.lineForScreenRow(1)).toEqual line4
|
||||
expect(map.lineForScreenRow(2)).toEqual line1
|
||||
expect(map.lineForScreenRow(3)).toEqual line2
|
||||
|
||||
|
||||
describe "when called with a row count greater than 1", ->
|
||||
it "replaces all line fragments spanning the multiple buffer rows with the given line fragments", ->
|
||||
[line1a, line1b] = line1.splitAt(10)
|
||||
|
||||
@@ -33,7 +33,7 @@ class LineMap
|
||||
delta = new Point
|
||||
|
||||
for screenLine, i in @screenLines
|
||||
startIndex = i if delta.row == startRow and not startIndex
|
||||
startIndex ?= i if delta.row == startRow
|
||||
nextDelta = delta.add(screenLine[deltaType])
|
||||
break if nextDelta.row > stopRow
|
||||
delta = nextDelta
|
||||
|
||||
Reference in New Issue
Block a user