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

Method MoveLinesUp

internal/buffer/buffer.go:1129–1151  ·  view source on GitHub ↗

MoveLinesUp moves the range of lines up one row

(start int, end int)

Source from the content-addressed store, hash-verified

1127
1128// MoveLinesUp moves the range of lines up one row
1129func (b *Buffer) MoveLinesUp(start int, end int) {
1130 if start < 1 || start >= end || end > len(b.lines) {
1131 return
1132 }
1133 l := string(b.LineBytes(start - 1))
1134 if end == len(b.lines) {
1135 b.insert(
1136 Loc{
1137 util.CharacterCount(b.lines[end-1].data),
1138 end - 1,
1139 },
1140 []byte{'\n'},
1141 )
1142 }
1143 b.Insert(
1144 Loc{0, end},
1145 l+"\n",
1146 )
1147 b.Remove(
1148 Loc{0, start - 1},
1149 Loc{0, start},
1150 )
1151}
1152
1153// MoveLinesDown moves the range of lines down one row
1154func (b *Buffer) MoveLinesDown(start int, end int) {

Callers

nothing calls this directly

Calls 5

InsertMethod · 0.95
RemoveMethod · 0.95
CharacterCountFunction · 0.92
LineBytesMethod · 0.65
insertMethod · 0.45

Tested by

no test coverage detected