From b8b219a1db0f7ca0c75a814e7d4bc39d78bff7da Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Mon, 13 Jun 2022 11:34:25 -0700 Subject: [PATCH] Display message when no edits take place --- jrnl/editor.py | 2 +- jrnl/jrnl.py | 5 ++++- jrnl/messages/MsgText.py | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jrnl/editor.py b/jrnl/editor.py index 91aa4d52..547f24f8 100644 --- a/jrnl/editor.py +++ b/jrnl/editor.py @@ -43,7 +43,7 @@ def get_text_from_editor(config, template=""): os.remove(tmpfile) if not raw: - raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.ERROR)) + raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL)) return raw diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 18ee4ed4..d634e2f2 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -141,7 +141,7 @@ def write_mode(args, config, journal, **kwargs): if not raw or raw.isspace(): logging.error("Write mode: couldn't get raw text or entry was empty") - raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.ERROR)) + raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL)) logging.debug( 'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw @@ -342,6 +342,9 @@ def _print_edited_summary(journal, old_stats, **kwargs): ) msgs.append(Message(my_msg, MsgStyle.NORMAL, {"num": stats["modified"]})) + if not msgs: + msgs.append(Message(MsgText.NoEditsReceived, MsgStyle.NORMAL)) + print_msgs(msgs) diff --git a/jrnl/messages/MsgText.py b/jrnl/messages/MsgText.py index f8e85b60..79234b0e 100644 --- a/jrnl/messages/MsgText.py +++ b/jrnl/messages/MsgText.py @@ -146,6 +146,8 @@ class MsgText(Enum): https://jrnl.sh/en/stable/external-editors/ """ + NoEditsReceived = "No edits to save, because nothing was changed" + NoTextReceived = """ No entry to save, because no text was received """