Called to reset the match index and update the word being replaced Should only be called if there's a target to update - otherwise, call clear
(
self,
cursor_offset: int,
current_line: str,
matches: list[str],
completer: autocomplete.BaseCompletionType,
)
| 301 | return new_cursor_offset, new_line |
| 302 | |
| 303 | def update( |
| 304 | self, |
| 305 | cursor_offset: int, |
| 306 | current_line: str, |
| 307 | matches: list[str], |
| 308 | completer: autocomplete.BaseCompletionType, |
| 309 | ) -> None: |
| 310 | """Called to reset the match index and update the word being replaced |
| 311 | |
| 312 | Should only be called if there's a target to update - otherwise, call |
| 313 | clear""" |
| 314 | |
| 315 | if matches is None: |
| 316 | raise ValueError("Matches may not be None.") |
| 317 | |
| 318 | self.orig_cursor_offset = cursor_offset |
| 319 | self.orig_line = current_line |
| 320 | self.matches = matches |
| 321 | self.completer = completer |
| 322 | self.index = -1 |
| 323 | lp = self.completer.locate(self.orig_cursor_offset, self.orig_line) |
| 324 | assert lp is not None |
| 325 | self.start = lp.start |
| 326 | self.end = lp.stop |
| 327 | self.current_word = lp.word |
| 328 | |
| 329 | def clear(self) -> None: |
| 330 | self.matches = [] |