Get undo working properly with multiple cursors

This commit is contained in:
Zachary Yedidia
2017-06-16 22:19:33 -04:00
parent 21840d3ffe
commit f933b90c66
5 changed files with 52 additions and 25 deletions

View File

@@ -28,8 +28,9 @@ type Buffer struct {
// This stores all the text in the buffer as an array of lines
*LineArray
Cursor Cursor
cursors []*Cursor // for multiple cursors
Cursor Cursor
cursors []*Cursor // for multiple cursors
curCursor int // the current cursor
// Path to the file on disk
Path string
@@ -308,6 +309,12 @@ func (b *Buffer) Update() {
b.NumLines = len(b.lines)
}
func (b *Buffer) UpdateCursors() {
for i, c := range b.cursors {
c.Num = i
}
}
// Save saves the buffer to its default path
func (b *Buffer) Save() error {
return b.SaveAs(b.Path)