From 00bc9ef3a1ca930259a784d1bf80612dd222c166 Mon Sep 17 00:00:00 2001 From: Briscoooe Date: Wed, 21 Dec 2022 10:26:11 +0000 Subject: [PATCH] Don't save templated journal entries if the received raw text is the same as the template itself --- jrnl/jrnl.py | 3 +++ jrnl/messages/MsgText.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index c79d46e0..601c146d 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -146,6 +146,9 @@ def write_mode(args: "Namespace", config: dict, journal: Journal, **kwargs) -> N 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.NORMAL)) + if config["template"] and raw == _get_editor_template(config): + logging.error("Write mode: raw text was the same as the template") + raise JrnlException(Message(MsgText.NoChangesToTemplate, MsgStyle.NORMAL)) logging.debug( 'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw diff --git a/jrnl/messages/MsgText.py b/jrnl/messages/MsgText.py index 8bcb7695..c090d985 100644 --- a/jrnl/messages/MsgText.py +++ b/jrnl/messages/MsgText.py @@ -156,7 +156,9 @@ class MsgText(Enum): NoTextReceived = """ No entry to save, because no text was received """ - + NoChangesToTemplate = """ + No entry to save, because the template was not changed + """ # --- Upgrade --- # JournalFailedUpgrade = """ The following journal{s} failed to upgrade: