(buffer: list[str], pos: int)
| 254 | |
| 255 | |
| 256 | def _should_auto_indent(buffer: list[str], pos: int) -> bool: |
| 257 | # check if last character before "pos" is a colon, ignoring |
| 258 | # whitespaces and comments. |
| 259 | last_char = None |
| 260 | while pos > 0: |
| 261 | pos -= 1 |
| 262 | if last_char is None: |
| 263 | if buffer[pos] not in " \t\n#": # ignore whitespaces and comments |
| 264 | last_char = buffer[pos] |
| 265 | else: |
| 266 | # even if we found a non-whitespace character before |
| 267 | # original pos, we keep going back until newline is reached |
| 268 | # to make sure we ignore comments |
| 269 | if buffer[pos] == "\n": |
| 270 | break |
| 271 | if buffer[pos] == "#": |
| 272 | last_char = None |
| 273 | return last_char == ":" |
| 274 | |
| 275 | |
| 276 | class maybe_accept(commands.Command): |
no outgoing calls
no test coverage detected
searching dependent graphs…