From a5f7e78d8dddbc4d3ec5944748e4a49504c4b1cf Mon Sep 17 00:00:00 2001 From: Bendt Date: Fri, 19 Dec 2025 14:54:40 -0500 Subject: [PATCH] Fix IndexError when pressing Escape to exit search mode Add bounds check in refresh_list_view_items() to handle cases where ListView and message_store.envelopes are temporarily out of sync during transitions (e.g., when exiting search mode). --- src/mail/app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mail/app.py b/src/mail/app.py index 915dd9a..9168876 100644 --- a/src/mail/app.py +++ b/src/mail/app.py @@ -543,6 +543,9 @@ class EmailViewerApp(App): envelopes_list = self.query_one("#envelopes_list", ListView) for i, list_item in enumerate(envelopes_list.children): if isinstance(list_item, ListItem): + # Bounds check - ListView and message_store may be out of sync during transitions + if i >= len(self.message_store.envelopes): + break item_data = self.message_store.envelopes[i] if item_data and item_data.get("type") != "header":