Fix deleteLines off-by-one error

Fixes #1501
This commit is contained in:
Zachary Yedidia 2020-02-12 01:16:11 -05:00
parent dcd4bae96f
commit 7d47659481

View file

@ -230,7 +230,7 @@ func (la *LineArray) remove(start, end Loc) []byte {
if start.Y == end.Y {
la.lines[start.Y].data = append(la.lines[start.Y].data[:startX], la.lines[start.Y].data[endX:]...)
} else {
la.deleteLines(start.Y, end.Y-1)
la.deleteLines(start.Y+1, end.Y-1)
la.deleteToEnd(Loc{startX, start.Y})
la.deleteFromStart(Loc{endX - 1, start.Y + 1})
la.joinLines(start.Y, start.Y+1)
@ -254,7 +254,7 @@ func (la *LineArray) deleteLine(y int) {
}
func (la *LineArray) deleteLines(y1, y2 int) {
la.lines = la.lines[:y1+copy(la.lines[y1:], la.lines[y2:])]
la.lines = la.lines[:y1+copy(la.lines[y1:], la.lines[y2+1:])]
}
// DeleteByte deletes the byte at a position