todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.56k stars 713 forks source link

prepend remove the status done on done tasks #268

Open Flyounet opened 5 years ago

Flyounet commented 5 years ago

Hi,

Thanks for the tool. I want to fill a bug regarding the prepend functionnality.

What is the current behavior? When you prepend on a done task, not yet moved in the done.txt, the text added move the task as todo.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

$; todo add "testing task"
16 2018-11-26 testing task
TODO: 16 added.

$; todo ls testing
16 2018-11-26 testing task
--
TODO: 1 of 16 tasks shown

$; todo do 16
16 x 2018-11-26 2018-11-26 testing task
TODO: 16 marked as done.

$; todo ls testing
16 x 2018-11-26 2018-11-26 testing task
--
TODO: 1 of 16 tasks shown

$; todo prepend 16 "test again"
16 test again x 2018-11-26 2018-11-26 testing task

$; todo ls testing
16 test again x 2018-11-26 2018-11-26 testing task
--
TODO: 1 of 16 tasks shown

What is the expected behavior? After prepending text the done task should remains done :

Taking the above example, the task should be :

16 x 2018-11-26 2018-11-26 test again testing task

Which versions todo.sh are you using?

Run todo.sh -V TODO.TXT Command Line Interface v2.11.0

Which Operating System are you using? GNU/Linux

Which version of bash are you using?

Run bash --version GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)

What to change in the code ? I suppose we should replace

local -r priAndDateExpr='^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}'

by

local -r priAndDateExpr='^\((.) \|[xX] \)\{0,1\}\(\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,2\}\)'
chrysle commented 1 year ago

That shouldn't be done indeed. I suppose it could be checked if the task is done before prepending, so that this can be turned of altogether or prepended after the x.