Copy the given text to the current buffer, overwriting the span 'start' to 'end'.
(buf, start, end, text)
| 18 | |
| 19 | |
| 20 | def _replace_text(buf, start, end, text): |
| 21 | """Copy the given text to the current buffer, overwriting the span 'start' |
| 22 | to 'end'.""" |
| 23 | lines = text.split("\n") |
| 24 | |
| 25 | new_end = _calc_end(lines, start) |
| 26 | |
| 27 | before = buf[start.line][: start.col] |
| 28 | after = buf[end.line][end.col :] |
| 29 | |
| 30 | new_lines = [] |
| 31 | if len(lines): |
| 32 | new_lines.append(before + lines[0]) |
| 33 | new_lines.extend(lines[1:]) |
| 34 | new_lines[-1] += after |
| 35 | buf[start.line : end.line + 1] = new_lines |
| 36 | |
| 37 | return new_end |
| 38 | |
| 39 | |
| 40 | class TextObject: |