the object.attribute.attribute just before or under the cursor
(cursor_offset: int, line: str)
| 24 | |
| 25 | |
| 26 | def 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 |
no test coverage detected