| 1226 | self.list_win_visible = self.complete(tab) |
| 1227 | |
| 1228 | def predicted_indent(self, line): |
| 1229 | # TODO get rid of this! It's repeated code! Combine with Repl. |
| 1230 | logger.debug("line is %r", line) |
| 1231 | indent = len(re.match(r"[ ]*", line).group()) |
| 1232 | if line.endswith(":"): |
| 1233 | indent = max(0, indent + self.config.tab_length) |
| 1234 | elif line and line.count(" ") == len(line): |
| 1235 | indent = max(0, indent - self.config.tab_length) |
| 1236 | elif ( |
| 1237 | line |
| 1238 | and ":" not in line |
| 1239 | and line.strip().startswith( |
| 1240 | ("return", "pass", "...", "raise", "yield", "break", "continue") |
| 1241 | ) |
| 1242 | ): |
| 1243 | indent = max(0, indent - self.config.tab_length) |
| 1244 | logger.debug("indent we found was %s", indent) |
| 1245 | return indent |
| 1246 | |
| 1247 | def push(self, line, insert_into_history=True) -> bool: |
| 1248 | """Push a line of code onto the buffer, start running the buffer |