Skip to content

Commit

Permalink
Display message when no edits take place (#1510)
Browse files Browse the repository at this point in the history
  • Loading branch information
apainintheneck committed Jun 25, 2022
1 parent 2805104 commit ed4f8ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jrnl/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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

Expand Down
5 changes: 4 additions & 1 deletion jrnl/jrnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions jrnl/messages/MsgText.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def __str__(self) -> str:
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
"""
Expand Down

0 comments on commit ed4f8ea

Please sign in to comment.