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

New tasks being added to old lines #340

Open AdamBD opened 3 years ago

AdamBD commented 3 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? Sometimes when adding tasks they are not added as new lines in the file but appended to some previous line

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

What is the expected behavior? Each addition will be added to a new line in the file

Which versions todo.sh are you using? TODO.TXT Command Line Interface v2.12.0

Which Operating System are you using? MacOS BigSur 11.2.1

Which version of bash are you using? zsh 5.8 (x86_64-apple-darwin20.0)

inkarkat commented 3 years ago

The core todo.sh has tests that ensure that this does not happen. It could be a misbehaving add-on that you're using, or are you "sometimes" editing the file in another editor? Some editors omit a final newline in the last line (especially on Windows), or this could also be caused by mismatching line endings (a.k.a. CR-LF vs. LF).

AdamBD commented 3 years ago

@inkarkat thanks for replying! I am indeed using another client in addition. I am using a mac client called sleek (https://github.com/ransome1/sleek), but the behavior I see can happen when just using this CLI. Any advice on ways to enforce the same line behavior?

inkarkat commented 3 years ago

Some clients have a setting (like Windows-friendly line breaks in Simpletask) to influence the behavior. But it would seem that such a mismatch would result in very reproducible corruption (e.g. whenever I add a task in the other client, todo.sh will then append to that if I use it next).

So maybe you could closely monitor when such corruption occurs for some time, and try to find a way to reproducibly cause corruption. As I said, just by using todo.sh itself (i.e. without synchronization of the todo.txt file and maybe another client running concurrently), I doubt that such problems can occur, and it's far more likely to be caused by something in the environment. Nonetheless, if you can find a reproducible example, we'll surely look into it.