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

Archiving and deleting broken when task creation date is missing #43

Closed
andrei-a-papou opened this issue Feb 17, 2024 · 7 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@andrei-a-papou
Copy link

andrei-a-papou commented Feb 17, 2024

When archiving or deleting, the task remains on screen, no message is printed in the status bar. If you hit the archive or delete shortcut again, pter v3.15.2 crashes with the following error:

[DEBUG] Current key sequence: ('%',)
[DEBUG] Calling archive
[DEBUG] Using archive file ~/.config/pter/archive.txt
[CRITICAL] Pter crashed with exception: list.remove(x): x not in list
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2-py3.11.egg/pter/curses.py", line 2941, in run_cursesui
    window.run()
  File "/usr/local/lib/python3.11/dist-packages/cursedspace-1.5.2-py3.11.egg/cursedspace/application.py", line 59, in run
    raise exception
  File "/usr/local/lib/python3.11/dist-packages/cursedspace-1.5.2-py3.11.egg/cursedspace/application.py", line 52, in run
    self.main()
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2-py3.11.egg/pter/curses.py", line 1734, in main
    self.functions[fnc]()
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2-py3.11.egg/pter/curses.py", line 2650, in do_archive
    success, task = self.modify_task(taskline, _do_delete)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2-py3.11.egg/pter/curses.py", line 2078, in modify_task
    fnc(task)
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2-py3.11.egg/pter/curses.py", line 2647, in _do_delete
    t.todotxt.tasks.remove(t)

Archiving and deleting work OK in 3.13.0, but not in later releases. Nope, also broken.

@andrei-a-papou
Copy link
Author

Strange, I can't reproduce it anymore... @vonshednob Can you?

@andrei-a-papou
Copy link
Author

OK, figured it out!

abc xyz 123 due:2024-12-12 <- this kind of task will trigger the bug
2023-01-01 abc xyz 123 due:2024-12-12 <- this kind of task will NOT trigger the bug

Missing creation date seems to be the culprit. I have tasks with and without it.

@andrei-a-papou andrei-a-papou changed the title Archiving and deleting broken since 3.14.0 Archiving and deleting broken when task creation date is missing Feb 17, 2024
@vonshednob
Copy link
Owner

Thanks for investigating! I'll see how to fix this

@vonshednob vonshednob added the bug Something isn't working label Feb 17, 2024
@vonshednob vonshednob self-assigned this Feb 17, 2024
@vonshednob
Copy link
Owner

I cannot reproduce the issue, but I cannot archive tasks either 😅 so I'm fixing that bug at least.

I also see how the bug that you describe could be triggered, but I don't understand how pter can get into this type of situation. I'll investigate some more.

@vonshednob
Copy link
Owner

Ah! I think I understand how this happened. Probably happened every 2nd time you try to archive a task; but the first time it doesn't actually archive it (because that was broken with an update to pytodotxt, I think).

The change is in how pter triggers the detection of a change in the task: task.parse(""), but with a more recent version(?) of pytodotxt parsing an empty string would not cause any change in the description, thus the task appears unchanged → problems.

Anyway, appears to be fixed for both deletion and archiving (not released yet, but the changes are in the codeberg repo).

@andrei-a-papou
Copy link
Author

Probably happened every 2nd time you try to archive a task; but the first time it doesn't actually archive it

I think so, yes. Try to archive the first time -- nothing appears to happen. Try to do it a second time -- pter crashes.

but I don't understand how pter can get into this type of situation

I've migrated my todo.txt from another tool and some of my todos had missing creation dates. That may have been a factor.

Thanks for fixing it, I'll test the code soon.

@andrei-a-papou
Copy link
Author

Tested, seems to work fine, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants