MergeCursors merges any cursors that are at the same position into one cursor
()
| 1070 | // MergeCursors merges any cursors that are at the same position |
| 1071 | // into one cursor |
| 1072 | func (b *Buffer) MergeCursors() { |
| 1073 | var cursors []*Cursor |
| 1074 | for i := 0; i < len(b.cursors); i++ { |
| 1075 | c1 := b.cursors[i] |
| 1076 | if c1 != nil { |
| 1077 | for j := 0; j < len(b.cursors); j++ { |
| 1078 | c2 := b.cursors[j] |
| 1079 | if c2 != nil && i != j && c1.Loc == c2.Loc { |
| 1080 | b.cursors[j] = nil |
| 1081 | } |
| 1082 | } |
| 1083 | cursors = append(cursors, c1) |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | b.cursors = cursors |
| 1088 | |
| 1089 | for i := range b.cursors { |
| 1090 | b.cursors[i].Num = i |
| 1091 | } |
| 1092 | |
| 1093 | if b.curCursor >= len(b.cursors) { |
| 1094 | b.curCursor = len(b.cursors) - 1 |
| 1095 | } |
| 1096 | b.EventHandler.cursors = b.cursors |
| 1097 | b.EventHandler.active = b.curCursor |
| 1098 | } |
| 1099 | |
| 1100 | // UpdateCursors updates all the cursors indices |
| 1101 | func (b *Buffer) UpdateCursors() { |
no outgoing calls
no test coverage detected