mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Fix bug in LineMap.spliceByDelta with multi-fragment screen lines
If the row following a row being replaced had multiple fragments, some of these fragments would be accidentally deleted.
This commit is contained in:
@@ -61,6 +61,10 @@ describe "LineMap", ->
|
||||
expect(map.lineForOutputRow(2)).toEqual line4
|
||||
expect(map.lineForOutputRow(3)).toEqual line2
|
||||
|
||||
map.spliceAtInputRow(2, 1, [line0])
|
||||
expect(map.lineForOutputRow(2)).toEqual line0
|
||||
expect(map.lineForOutputRow(3)).toEqual line2
|
||||
|
||||
describe "when the specified buffer row is spanned by multiple line fragments", ->
|
||||
it "replaces all spanning line fragments with the given line fragments", ->
|
||||
[line1a, line1b] = line1.splitAt(10)
|
||||
@@ -75,6 +79,18 @@ describe "LineMap", ->
|
||||
expect(map.lineForOutputRow(2)).toEqual line4
|
||||
expect(map.lineForOutputRow(3)).toEqual line2
|
||||
|
||||
describe "when the row following the specified buffer row is spanned by multiple line fragments", ->
|
||||
it "replaces the specified row, but no portion of the following row", ->
|
||||
[line3a, line3b] = line3.splitAt(10)
|
||||
|
||||
map.insertAtInputRow(0, [line0, line1, line2, line3a, line3b])
|
||||
map.spliceAtInputRow(2, 1, [line4])
|
||||
|
||||
expect(map.lineForOutputRow(0)).toEqual line0
|
||||
expect(map.lineForOutputRow(1)).toEqual line1
|
||||
expect(map.lineForOutputRow(2)).toEqual line4
|
||||
expect(map.lineForOutputRow(3)).toEqual line3a.concat(line3b)
|
||||
|
||||
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)
|
||||
|
||||
@@ -76,9 +76,8 @@ class LineMap
|
||||
delta = new Point
|
||||
for lineFragment, i in @lineFragments
|
||||
startIndex ?= i if delta.row == startRow
|
||||
break if rowCount == 0 and delta.row == stopRow
|
||||
break if delta.row == stopRow
|
||||
delta = delta.add(lineFragment[deltaType])
|
||||
break if delta.row > stopRow
|
||||
stopIndex++
|
||||
startIndex ?= i
|
||||
|
||||
|
||||
Reference in New Issue
Block a user