🐛 Fix inaccurate logic in moveLineDown

Instead of deleting and then inserting, it’s better to do the opposite
so that we don’t have to translate points at all.
This commit is contained in:
Antonio Scandurra
2016-03-23 16:16:51 +01:00
parent 3d9835bbbd
commit 21831a4e43

View File

@@ -1016,13 +1016,12 @@ class TextEditor extends Model
.map((range) -> range.translate([insertDelta, 0]))
# Delete lines spanned by selection and insert them on the following correct buffer row
insertPosition = new Point(selection.translate([insertDelta, 0]).start.row, 0)
lines = @buffer.getTextInRange(linesRange)
if linesRange.end.row is @buffer.getLastRow()
lines = "\n#{lines}"
@buffer.insert([followingRow, 0], lines)
@buffer.delete(linesRange)
@buffer.insert(insertPosition, lines)
# Restore folds that existed before the lines were moved
for rangeToRefold in rangesToRefold