Skip to content

Commit a6aae3e

Browse files
committed
views/boxes: Reset search only after verifying search status.
Added conditional checks to ensure that a search was previously performed before resetting search, using the newly added search_status.
1 parent 04a83f8 commit a6aae3e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

zulipterminal/ui_tools/boxes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
10101010
self.reset_search_text()
10111011
self.panel_view.set_focus("body")
10121012
# Don't call 'Esc' when inside a popup search-box.
1013-
if not self.panel_view.view.controller.is_any_popup_open():
1013+
if (
1014+
not self.panel_view.view.controller.is_any_popup_open()
1015+
and self.panel_view.search_status != SearchStatus.DEFAULT
1016+
):
10141017
self.panel_view.keypress(size, primary_key_for_command("GO_BACK"))
10151018
elif (
10161019
is_command_key("EXECUTE_SEARCH", key)

zulipterminal/ui_tools/views.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
403403
self.stream_search_box.set_caption(" ")
404404
self.view.controller.enter_editor_mode_with(self.stream_search_box)
405405
return key
406-
elif is_command_key("GO_BACK", key):
406+
elif (
407+
is_command_key("GO_BACK", key)
408+
and self.search_status != SearchStatus.DEFAULT
409+
):
407410
self.stream_search_box.reset_search_text()
408411
self.log.clear()
409412
self.log.extend(self.streams_btn_list)
@@ -528,7 +531,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
528531
self.topic_search_box.set_caption(" ")
529532
self.view.controller.enter_editor_mode_with(self.topic_search_box)
530533
return key
531-
elif is_command_key("GO_BACK", key):
534+
elif (
535+
is_command_key("GO_BACK", key)
536+
and self.search_status != SearchStatus.DEFAULT
537+
):
532538
self.topic_search_box.reset_search_text()
533539
self.log.clear()
534540
self.log.extend(self.topics_btn_list)
@@ -772,7 +778,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
772778
self.user_search.set_caption(" ")
773779
self.view.controller.enter_editor_mode_with(self.user_search)
774780
return key
775-
elif is_command_key("GO_BACK", key):
781+
elif (
782+
is_command_key("GO_BACK", key)
783+
and self.search_status != SearchStatus.DEFAULT
784+
):
776785
self.user_search.reset_search_text()
777786
self.allow_update_user_list = True
778787
self.body = UsersView(self.view.controller, self.users_btn_list)

0 commit comments

Comments
 (0)