From af9731f3ca47f448c484efbbf07e5b91ba4e1a72 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 7 Dec 2023 07:45:30 +0000 Subject: [PATCH] Prevent accidentally stacking multiple [ESC][R]. Now, if you [ESC] to get to where you already were, it will just go back to the existing stack entry. (But maybe this still isn't strong enough? Perhaps we need to search for it all the way up?) --- cursesclient.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cursesclient.py b/cursesclient.py index 58fc2ec..0583035 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -253,7 +253,11 @@ class Menu: def chain_to(self, activity): assert self.cc.activity_stack[-1] is self - self.cc.activity_stack[-1] = activity + if (len(self.cc.activity_stack) > 1 and + self.cc.activity_stack[-2] == activity): + self.cc.activity_stack.pop() + else: + self.cc.activity_stack[-1] = activity def push_to(self, activity): self.cc.activity_stack.append(activity) -- 2.30.2