diff --git a/spec/atom/line-map-spec.coffee b/spec/atom/line-map-spec.coffee index a93d8b6a9..1e89ebfb1 100644 --- a/spec/atom/line-map-spec.coffee +++ b/spec/atom/line-map-spec.coffee @@ -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) diff --git a/src/atom/line-map.coffee b/src/atom/line-map.coffee index fe5cd78c0..0ad0c9a84 100644 --- a/src/atom/line-map.coffee +++ b/src/atom/line-map.coffee @@ -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