removes from start to end
(start, end Loc)
| 249 | |
| 250 | // removes from start to end |
| 251 | func (la *LineArray) remove(start, end Loc) []byte { |
| 252 | la.lock.Lock() |
| 253 | defer la.lock.Unlock() |
| 254 | |
| 255 | sub := la.Substr(start, end) |
| 256 | startX := runeToByteIndex(start.X, la.lines[start.Y].data) |
| 257 | endX := runeToByteIndex(end.X, la.lines[end.Y].data) |
| 258 | if start.Y == end.Y { |
| 259 | la.lines[start.Y].data = append(la.lines[start.Y].data[:startX], la.lines[start.Y].data[endX:]...) |
| 260 | } else { |
| 261 | la.deleteLines(start.Y+1, end.Y-1) |
| 262 | la.deleteToEnd(Loc{startX, start.Y}) |
| 263 | la.deleteFromStart(Loc{endX - 1, start.Y + 1}) |
| 264 | la.joinLines(start.Y, start.Y+1) |
| 265 | } |
| 266 | return sub |
| 267 | } |
| 268 | |
| 269 | // deleteToEnd deletes from the end of a line to the position |
| 270 | func (la *LineArray) deleteToEnd(pos Loc) { |
nothing calls this directly
no test coverage detected