delete line behaviour is fixed

This commit is contained in:
Felix Angell 2018-04-17 14:34:24 +01:00
parent a8b2cf1f4c
commit c2f1796bc2

View File

@ -3,22 +3,23 @@ package gui
import rope "github.com/felixangell/go-rope"
func DeleteLine(b *Buffer) bool {
if b.curs.y == 0 {
var prevLineLen = 0
if len(b.contents) > 1 {
prevLineLen = b.contents[b.curs.y].Len()
b.contents = remove(b.contents, b.curs.y)
} else {
// we are on the first line
// and there is nothing else to delete
// so we just clear the line
b.contents[b.curs.y] = new(rope.Rope)
b.moveToEndOfLine()
return false
return true
}
if b.curs.y >= len(b.contents) {
return false
}
prevLineLen := b.contents[b.curs.y].Len()
b.contents = remove(b.contents, b.curs.y)
if b.curs.y >= len(b.contents) {
b.moveUp()
b.moveToEndOfLine()
if b.curs.y > 0 {
b.moveUp()
}
return false
}