From: Simon Tatham Date: Thu, 7 Dec 2023 07:45:30 +0000 (+0000) Subject: Prevent accidentally stacking multiple [ESC][R]. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=af9731f3ca47f448c484efbbf07e5b91ba4e1a72;p=mastodonochrome.git 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?) --- 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)