Permalink
Browse files

FIX: Replacement with priority and date doesn't replace existing date.

  • Loading branch information...
1 parent ebe6a40 commit 24d0fb003a8ef486c37a53cb80d28872922e206c @inkarkat inkarkat committed Apr 19, 2012
Showing with 11 additions and 3 deletions.
  1. +8 −0 tests/t1100-replace.sh
  2. +3 −3 todo.sh
View
8 tests/t1100-replace.sh
@@ -164,4 +164,12 @@ TODO: Replaced task with:
1 (A) 2010-07-04 this also has a new date
EOF
+echo '2009-02-13 this is just a new one' > todo.txt
+test_todo_session 'replace with prepended priority and date replaces existing date' <<EOF
+>>> todo.sh replace 1 '(B) 2010-07-04 this also has a new date'
+1 2009-02-13 this is just a new one
+TODO: Replaced task with:
+1 (B) 2010-07-04 this also has a new date
+EOF
+
test_done
View
6 todo.sh
@@ -395,9 +395,9 @@ replaceOrPrepend()
priority=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE")
prepdate=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE")
- if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\}\)\{0,1\}.*/\1/')" ]; then
- # If the replaced text starts with a date, it will replace the existing
- # date, too.
+ if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1\2/')" ]; then
+ # If the replaced text starts with a [priority +] date, it will replace
+ # the existing date, too.
prepdate=
fi

0 comments on commit 24d0fb0

Please sign in to comment.