Skip to content

Commit

Permalink
feat: press escape to reset modified state
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Sep 19, 2024
1 parent ddf6d8a commit a0361e9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dooit/ui/widgets/trees/model_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def stop_edit(self):
self.current.stop_edit()
self.app.post_message(ModeChanged("NORMAL"))

def reset_state(self):
"""
Reset tree of any modified status for e.g. search
"""
self.set_filter("")

async def handle_key(self, event: events.Key) -> bool:
key = event.key
if self.is_editing:
Expand All @@ -133,6 +139,9 @@ async def handle_key(self, event: events.Key) -> bool:
self.refresh_options()
return True
else:
if key == "escape":
self.reset_state()

return await super().handle_key(event)

def refresh_options(self) -> None:
Expand Down

0 comments on commit a0361e9

Please sign in to comment.