Skip to content

Commit 4f15cac

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 0bf31b7 commit 4f15cac

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Diff for: zulipterminal/ui_tools/boxes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
10421042
self.reset_search_text()
10431043
self.panel_view.set_focus("body")
10441044
# Don't call 'Esc' when inside a popup search-box.
1045-
if not self.panel_view.view.controller.is_any_popup_open():
1045+
if (
1046+
not self.panel_view.view.controller.is_any_popup_open()
1047+
and self.panel_view.search_status != SearchStatus.DEFAULT
1048+
):
10461049
self.panel_view.keypress(size, primary_key_for_command("CLEAR_SEARCH"))
10471050
elif (
10481051
is_command_key("EXECUTE_SEARCH", key)

Diff for: 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("CLEAR_SEARCH", key):
406+
elif (
407+
is_command_key("CLEAR_SEARCH", 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("CLEAR_SEARCH", key):
534+
elif (
535+
is_command_key("CLEAR_SEARCH", 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("CLEAR_SEARCH", key):
781+
elif (
782+
is_command_key("CLEAR_SEARCH", 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)