chiark / gitweb /
Prevent accidentally stacking multiple [ESC][R].
authorSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 07:45:30 +0000 (07:45 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 07:45:30 +0000 (07:45 +0000)
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

index 58fc2ec32ee86484f58c34bd199b4f2d3cfe749b..0583035367b56b774346462c81a7d820fc5d68da 100644 (file)
@@ -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)