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).
This commit is contained in:
@@ -543,6 +543,9 @@ class EmailViewerApp(App):
|
|||||||
envelopes_list = self.query_one("#envelopes_list", ListView)
|
envelopes_list = self.query_one("#envelopes_list", ListView)
|
||||||
for i, list_item in enumerate(envelopes_list.children):
|
for i, list_item in enumerate(envelopes_list.children):
|
||||||
if isinstance(list_item, ListItem):
|
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]
|
item_data = self.message_store.envelopes[i]
|
||||||
|
|
||||||
if item_data and item_data.get("type") != "header":
|
if item_data and item_data.get("type") != "header":
|
||||||
|
|||||||
Reference in New Issue
Block a user