Skip to content

Commit

Permalink
refactor: boxes: Extract exit compose box logic into a new method.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsashank authored and neiljp committed Jul 14, 2024
1 parent 66c74ba commit d3251f2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ def autocomplete_emojis(

return emoji_typeahead, emojis

def exit_compose_box(self) -> None:
self._set_compose_attributes_to_defaults()
self.view.controller.exit_editor_mode()
self.main_view(False)
self.view.middle_column.set_focus("body")

def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
if self.is_in_typeahead_mode and not (
is_command_key("AUTOCOMPLETE", key)
Expand Down Expand Up @@ -800,10 +806,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
)
elif is_command_key("EXIT_COMPOSE", key):
self.send_stop_typing_status()
self._set_compose_attributes_to_defaults()
self.view.controller.exit_editor_mode()
self.main_view(False)
self.view.middle_column.set_focus("body")
self.exit_compose_box()
elif is_command_key("MARKDOWN_HELP", key):
self.view.controller.show_markdown_help()
return key
Expand Down

0 comments on commit d3251f2

Please sign in to comment.