bpython.Repl.undo calls this
(self, new_code=False)
| 1981 | self.status_bar.message("Nothing to redo.") |
| 1982 | |
| 1983 | def reevaluate(self, new_code=False): |
| 1984 | """bpython.Repl.undo calls this""" |
| 1985 | if self.watcher: |
| 1986 | self.watcher.reset() |
| 1987 | old_logical_lines = self.history |
| 1988 | old_display_lines = self.display_lines |
| 1989 | self.history = [] |
| 1990 | self.display_lines = [] |
| 1991 | self.all_logical_lines = [] |
| 1992 | |
| 1993 | if not self.weak_rewind: |
| 1994 | self.interp = self.interp.__class__() |
| 1995 | self.interp.write = self.send_to_stdouterr |
| 1996 | self.coderunner.interp = self.interp |
| 1997 | self.initialize_interp() |
| 1998 | |
| 1999 | self.buffer = [] |
| 2000 | self.display_buffer = [] |
| 2001 | self.highlighted_paren = None |
| 2002 | |
| 2003 | self.process_event(bpythonevents.RunStartupFileEvent()) |
| 2004 | self.reevaluating = True |
| 2005 | sys.stdin = ReevaluateFakeStdin(self.stdin, self) |
| 2006 | for line in old_logical_lines: |
| 2007 | self._current_line = line |
| 2008 | self.on_enter(new_code=new_code) |
| 2009 | while self.fake_refresh_requested: |
| 2010 | self.fake_refresh_requested = False |
| 2011 | self.process_event(bpythonevents.RefreshRequestEvent()) |
| 2012 | sys.stdin = self.stdin |
| 2013 | self.reevaluating = False |
| 2014 | |
| 2015 | num_lines_onscreen = len(self.lines_for_display) - max( |
| 2016 | 0, self.scroll_offset |
| 2017 | ) |
| 2018 | display_lines_offscreen = self.display_lines[ |
| 2019 | : len(self.display_lines) - num_lines_onscreen |
| 2020 | ] |
| 2021 | old_display_lines_offscreen = old_display_lines[ |
| 2022 | : (len(self.display_lines) - num_lines_onscreen) |
| 2023 | ] |
| 2024 | logger.debug( |
| 2025 | "old_display_lines_offscreen %s", |
| 2026 | "|".join(str(x) for x in old_display_lines_offscreen), |
| 2027 | ) |
| 2028 | logger.debug( |
| 2029 | " display_lines_offscreen %s", |
| 2030 | "|".join(str(x) for x in display_lines_offscreen), |
| 2031 | ) |
| 2032 | if ( |
| 2033 | old_display_lines_offscreen[: len(display_lines_offscreen)] |
| 2034 | != display_lines_offscreen |
| 2035 | ) and not self.history_already_messed_up: |
| 2036 | self.inconsistent_history = True |
| 2037 | logger.debug( |
| 2038 | "after rewind, self.inconsistent_history is %r", |
| 2039 | self.inconsistent_history, |
| 2040 | ) |
no test coverage detected