mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 19:20:21 +03:00
delete line behaviour is fixed
This commit is contained in:
parent
a8b2cf1f4c
commit
c2f1796bc2
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user