MCPcopy Index your code
hub / github.com/bpython/bpython / current_word

Function current_word

bpython/line.py:26–38  ·  view source on GitHub ↗

the object.attribute.attribute just before or under the cursor

(cursor_offset: int, line: str)

Source from the content-addressed store, hash-verified

24
25
26def current_word(cursor_offset: int, line: str) -> LinePart | None:
27 """the object.attribute.attribute just before or under the cursor"""
28 start = cursor_offset
29 end = cursor_offset
30 word = None
31 for m in _current_word_re.finditer(line):
32 if m.start(1) < cursor_offset <= m.end(1):
33 start = m.start(1)
34 end = m.end(1)
35 word = m.group(1)
36 if word is None:
37 return None
38 return LinePart(start, end, word)
39
40
41# pieces of regex to match repr() of several hashable built-in types

Callers 4

completeMethod · 0.85
current_objectFunction · 0.85
current_object_attributeFunction · 0.85
current_dotted_attributeFunction · 0.85

Calls 3

LinePartClass · 0.85
finditerMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected