MCPcopy Create free account
hub / github.com/bpython/bpython / undo

Method undo

bpython/repl.py:1053–1075  ·  view source on GitHub ↗

Go back in the undo history n steps and call reevaluate() Note that in the program this is called "Rewind" because I want it to be clear that this is by no means a true undo implementation, it is merely a convenience bonus.

(self, n: int = 1)

Source from the content-addressed store, hash-verified

1051 return n
1052
1053 def undo(self, n: int = 1) -> None:
1054 """Go back in the undo history n steps and call reevaluate()
1055 Note that in the program this is called "Rewind" because I
1056 want it to be clear that this is by no means a true undo
1057 implementation, it is merely a convenience bonus."""
1058 if not self.history:
1059 return None
1060
1061 self.interp.timer.reset_timer()
1062
1063 if len(self.history) < n:
1064 n = len(self.history)
1065
1066 entries = list(self.rl_history.entries)
1067
1068 # Most recently undone command
1069 last_entries = self.history[-n:]
1070 last_entries.reverse()
1071 self.redo_stack += last_entries
1072 self.history = self.history[:-n]
1073 self.reevaluate()
1074
1075 self.rl_history.entries = entries
1076
1077 def flush(self) -> None:
1078 """Olivier Grisel brought it to my attention that the logging

Callers

nothing calls this directly

Calls 2

reevaluateMethod · 0.95
reset_timerMethod · 0.80

Tested by

no test coverage detected