If in from import completion, the word after import being completed returns None if cursor not in or just after one of these words
(
cursor_offset: int, line: str
)
| 188 | |
| 189 | |
| 190 | def current_from_import_import( |
| 191 | cursor_offset: int, line: str |
| 192 | ) -> LinePart | None: |
| 193 | """If in from import completion, the word after import being completed |
| 194 | |
| 195 | returns None if cursor not in or just after one of these words |
| 196 | """ |
| 197 | baseline = _current_from_import_import_re_1.search(line) |
| 198 | if baseline is None: |
| 199 | return None |
| 200 | match1 = _current_from_import_import_re_2.search(line[baseline.end() :]) |
| 201 | if match1 is None: |
| 202 | return None |
| 203 | for m in chain( |
| 204 | (match1,), |
| 205 | _current_from_import_import_re_3.finditer(line[baseline.end() :]), |
| 206 | ): |
| 207 | start = baseline.end() + m.start(1) |
| 208 | end = baseline.end() + m.end(1) |
| 209 | if start < cursor_offset <= end: |
| 210 | return LinePart(start, end, m.group(1)) |
| 211 | return None |
| 212 | |
| 213 | |
| 214 | _current_import_re_1 = LazyReCompile(r"import") |