Skip to content

Commit b433eb8

Browse files
committed
view: Fix focus index before and after Panel Search.
This commit corrects what the code for focus_index_before_search was intended to do. The focus index was still being updated even in the search results. This is fixed by moving `get_focus` into the SEARCH_STREAM/TOPIC conditional. Fixes zulip#975
1 parent 51e5344 commit b433eb8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

zulipterminal/ui_tools/views.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ def mouse_event(
367367

368368
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
369369
if is_command_key("SEARCH_STREAMS", key):
370+
_, self.focus_index_before_search = self.log.get_focus()
370371
self.set_focus("header")
371372
return key
372373
elif is_command_key("GO_BACK", key):
@@ -377,9 +378,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
377378
self.log.set_focus(self.focus_index_before_search)
378379
self.view.controller.update_screen()
379380
return key
380-
return_value = super().keypress(size, key)
381-
_, self.focus_index_before_search = self.log.get_focus()
382-
return return_value
381+
return super().keypress(size, key)
383382

384383

385384
class TopicsView(urwid.Frame):
@@ -482,6 +481,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
482481
self.view.show_left_panel(visible=False)
483482
self.view.body.focus_col = 1
484483
if is_command_key("SEARCH_TOPICS", key):
484+
_, self.focus_index_before_search = self.log.get_focus()
485485
self.set_focus("header")
486486
self.header_list.set_focus(2)
487487
return key
@@ -493,9 +493,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
493493
self.log.set_focus(self.focus_index_before_search)
494494
self.view.controller.update_screen()
495495
return key
496-
return_value = super().keypress(size, key)
497-
_, self.focus_index_before_search = self.log.get_focus()
498-
return return_value
496+
return super().keypress(size, key)
499497

500498

501499
class UsersView(urwid.ListBox):

0 commit comments

Comments
 (0)