Fix multiline remove in lineArray

I forgot that when you remove lines[n] then lines[n+1] becomes lines[n]
so to remove the range lines[a:b] you need to remove lines[a] for a-b
times. In this case we should delete lines[start.Y + 1] over and over
instead of removing lines[i] because i is contantly increasing.

Fixes #166
This commit is contained in:
Zachary Yedidia
2016-06-08 10:21:27 -04:00
parent bd0fa7b6c2
commit 3080e32a8f

View File

@@ -92,7 +92,7 @@ func (la *LineArray) remove(start, end Loc) string {
la.lines[start.Y] = append(la.lines[start.Y][:startX], la.lines[start.Y][endX:]...)
} else {
for i := start.Y + 1; i <= end.Y-1; i++ {
la.DeleteLine(i)
la.DeleteLine(start.Y + 1)
}
la.DeleteToEnd(Loc{startX, start.Y})
la.DeleteFromStart(Loc{endX - 1, start.Y + 1})