(self)
| 165 | |
| 166 | class complete(commands.Command): |
| 167 | def do(self) -> None: |
| 168 | r: CompletingReader |
| 169 | r = self.reader # type: ignore[assignment] |
| 170 | last_is_completer = r.last_command_is(self.__class__) |
| 171 | immutable_completions = r.assume_immutable_completions |
| 172 | completions_unchangable = last_is_completer and immutable_completions |
| 173 | stem = r.get_stem() |
| 174 | if not completions_unchangable: |
| 175 | r.cmpltn_menu_choices = r.get_completions(stem) |
| 176 | |
| 177 | completions = r.cmpltn_menu_choices |
| 178 | if not completions: |
| 179 | r.error("no matches") |
| 180 | elif len(completions) == 1: |
| 181 | if completions_unchangable and len(completions[0]) == len(stem): |
| 182 | r.msg = "[ sole completion ]" |
| 183 | r.dirty = True |
| 184 | r.insert(completions[0][len(stem):]) |
| 185 | else: |
| 186 | p = prefix(completions, len(stem)) |
| 187 | if p: |
| 188 | r.insert(p) |
| 189 | if last_is_completer: |
| 190 | r.cmpltn_menu_visible = True |
| 191 | r.cmpltn_message_visible = False |
| 192 | r.cmpltn_menu, r.cmpltn_menu_end = build_menu( |
| 193 | r.console, completions, r.cmpltn_menu_end, |
| 194 | r.use_brackets, r.sort_in_column) |
| 195 | r.dirty = True |
| 196 | elif not r.cmpltn_menu_visible: |
| 197 | r.cmpltn_message_visible = True |
| 198 | if stem + p in completions: |
| 199 | r.msg = "[ complete but not unique ]" |
| 200 | r.dirty = True |
| 201 | else: |
| 202 | r.msg = "[ not unique ]" |
| 203 | r.dirty = True |
| 204 | |
| 205 | |
| 206 | class self_insert(commands.self_insert): |
no test coverage detected