MCPcopy Create free account
hub / github.com/bpython/bpython / substitute

Method substitute

bpython/autocomplete.py:265–273  ·  view source on GitHub ↗

Returns a cursor offset and line with match swapped in

(
        self, cursor_offset: int, line: str, match: str
    )

Source from the content-addressed store, hash-verified

263 return word
264
265 def substitute(
266 self, cursor_offset: int, line: str, match: str
267 ) -> tuple[int, str]:
268 """Returns a cursor offset and line with match swapped in"""
269 lpart = self.locate(cursor_offset, line)
270 assert lpart
271 offset = lpart.start + len(match)
272 changed_line = line[: lpart.start] + match + line[lpart.stop :]
273 return offset, changed_line
274
275 @property
276 def shown_before_tab(self) -> bool:

Callers

nothing calls this directly

Calls 1

locateMethod · 0.95

Tested by

no test coverage detected