Skip to content

Commit cbe7707

Browse files
committed
Fix unbounded undo stack growth bug
1 parent d7311af commit cbe7707

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/_pyrepl/reader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,10 @@ def do_cmd(self, cmd: tuple[str, list[str]]) -> None:
780780
return # nothing to do
781781

782782
command = command_type(self, *cmd) # type: ignore[arg-type]
783-
784783
# Save undo state in vi mode if the command modifies the buffer
785784
if self.use_vi_mode and getattr(command_type, 'modifies_buffer', False):
785+
if len(self.undo_stack) > MAX_VI_UNDO_STACK_SIZE:
786+
self.undo_stack.pop(0)
786787
self.undo_stack.append(ViUndoState(
787788
buffer_snapshot=self.buffer.copy(),
788789
pos_snapshot=self.pos,

0 commit comments

Comments
 (0)