MCPcopy
hub / github.com/SirVer/ultisnips / _replace_text

Function _replace_text

pythonx/UltiSnips/text_objects/base.py:20–37  ·  view source on GitHub ↗

Copy the given text to the current buffer, overwriting the span 'start' to 'end'.

(buf, start, end, text)

Source from the content-addressed store, hash-verified

18
19
20def _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
40class TextObject:

Callers 1

overwriteMethod · 0.85

Calls 2

_calc_endFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected