From fce5afff0632a273de1713bc3a3f6f90c6b7706a Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Fri, 11 Nov 2022 15:37:25 -0600 Subject: [PATCH] Bail out of search_mode before editing (rather than after) if no entries match the search --- jrnl/jrnl.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index c79d46e0..202af212 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -183,8 +183,12 @@ def search_mode(args: "Namespace", journal: Journal, **kwargs) -> None: _filter_journal_entries(**kwargs) _print_entries_found_count(len(journal), args) + if not journal: + # Bail out if there are no entries + return + # Where do the search results go? - if args.edit: + elif args.edit: # If we want to both edit and change time in one action if args.change_time: # Generate a new list instead of assigning so it won't be @@ -202,11 +206,6 @@ def search_mode(args: "Namespace", journal: Journal, **kwargs) -> None: journal.entries = selected_entries _edit_search_results(**kwargs) - - elif not journal: - # Bail out if there are no entries and we're not editing - return - elif args.change_time: _change_time_search_results(**kwargs)