Merge cursors properly

Cursors will merge together if they are on top of each other.
This commit is contained in:
Zachary Yedidia
2017-06-17 10:43:14 -04:00
parent f933b90c66
commit 118e6b1804
3 changed files with 26 additions and 8 deletions

View File

@@ -309,6 +309,24 @@ func (b *Buffer) Update() {
b.NumLines = len(b.lines)
}
func (b *Buffer) MergeCursors() {
var cursors []*Cursor
for i := 0; i < len(b.cursors); i++ {
c1 := b.cursors[i]
if c1 != nil {
for j := 0; j < len(b.cursors); j++ {
c2 := b.cursors[j]
if i != j && c1.Loc == c2.Loc {
b.cursors[j] = nil
}
}
cursors = append(cursors, c1)
}
}
b.cursors = cursors
}
func (b *Buffer) UpdateCursors() {
for i, c := range b.cursors {
c.Num = i