MCPcopy
hub / github.com/micro-editor/micro / MergeCursors

Method MergeCursors

internal/buffer/buffer.go:1072–1098  ·  view source on GitHub ↗

MergeCursors merges any cursors that are at the same position into one cursor

()

Source from the content-addressed store, hash-verified

1070// MergeCursors merges any cursors that are at the same position
1071// into one cursor
1072func (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
1101func (b *Buffer) UpdateCursors() {

Callers 7

HandleEventMethod · 0.80
SpawnMultiCursorMethod · 0.80
SpawnCursorAtLocMethod · 0.80
SpawnMultiCursorUpNMethod · 0.80
MouseMultiCursorMethod · 0.80
skipMultiCursorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected