Fix small bug related to starring an entry with a date

If a date was given with an entry, and the star was also was added, the
star wouldn't be recognized if it was at the start of the title.

Example that didn't work, but now works with this fix:
  jrnl "saturday: *Title words."

This is to be consistent in starring functionality with and without a
date in the entry.
This commit is contained in:
Jonathan Wren 2020-07-03 14:43:48 -07:00
parent 41d06bfc65
commit bbd09e03c4
3 changed files with 7 additions and 2 deletions

View file

@ -279,7 +279,12 @@ class Journal:
if date: # Parsed successfully, strip that from the raw text if date: # Parsed successfully, strip that from the raw text
starred = raw[:colon_pos].strip().endswith("*") starred = raw[:colon_pos].strip().endswith("*")
raw = raw[colon_pos + 1 :].strip() raw = raw[colon_pos + 1 :].strip()
starred = starred or first_line.startswith("*") or first_line.endswith("*") starred = (
starred
or first_line.startswith("*")
or first_line.endswith("*")
or raw.startswith("*")
)
if not date: # Still nothing? Meh, just live in the moment. if not date: # Still nothing? Meh, just live in the moment.
date = time.parse("now") date = time.parse("now")
entry = Entry.Entry(self, date, raw, starred=starred) entry = Entry.Entry(self, date, raw, starred=starred)

View file

@ -25,7 +25,7 @@ import platform
import sys import sys
from . import install, plugins, util from . import install, plugins, util
from .parsing import parse_args from .parse_args import parse_args
from .Journal import PlainJournal, open_journal from .Journal import PlainJournal, open_journal
from .util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR, UserAbort from .util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR, UserAbort
from .util import get_journal_name from .util import get_journal_name