Fix glitch with undo

This commit is contained in:
Zachary Yedidia
2016-06-07 16:10:39 -04:00
parent f0b6725000
commit 8d184c1870
2 changed files with 3 additions and 3 deletions

View File

@@ -269,7 +269,7 @@ func (b *Buffer) Start() Loc {
// End returns the location of the last character in the buffer
func (b *Buffer) End() Loc {
return Loc{utf8.RuneCount(b.lines[len(b.lines)-1]), b.NumLines - 1}
return Loc{utf8.RuneCount(b.lines[b.NumLines-1]), b.NumLines - 1}
}
// Line returns a single line

View File

@@ -85,7 +85,7 @@ func (l Loc) LessEqual(b Loc) bool {
func (l Loc) right(buf *Buffer) Loc {
if l == buf.End() {
return l
return Loc{l.X + 1, l.Y}
}
var res Loc
if l.X < Count(buf.Line(l.Y)) {
@@ -97,7 +97,7 @@ func (l Loc) right(buf *Buffer) Loc {
}
func (l Loc) left(buf *Buffer) Loc {
if l == buf.Start() {
return l
return Loc{l.X - 1, l.Y}
}
var res Loc
if l.X > 0 {