Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display message when no edits take place #1510

Merged
merged 1 commit into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jrnl/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

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 @@ -146,6 +146,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