Skip to content

Commit

Permalink
comment: Explain the new recurrence status logic
Browse files Browse the repository at this point in the history
The comments were kindly written by @asokawotulo in:
#2516 (comment)

Co-Authored-By: Asoka Wotulo <32058490+asokawotulo@users.noreply.github.com>
  • Loading branch information
claremacrae and asokawotulo committed Dec 22, 2023
1 parent 10ef903 commit 0495f5a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,16 @@ export class Task {
let nextStatus = statusRegistry.getNextStatusOrCreate(newStatus);
if (nextStatus.type !== StatusType.TODO) {
let searchStatus = nextStatus;
// The goal here is to avoid an infinite loop. By limiting the search to the number of
// configured statuses, we ensure it doesn't continue indefinitely.
for (let i = 0; i < statusRegistry.registeredStatuses.length - 1; i++) {
searchStatus = statusRegistry.getNextStatusOrCreate(searchStatus);
if (searchStatus.type === StatusType.TODO) {
nextStatus = searchStatus;
break;
}
}
// If it fails to find any TODO status, it will use the next symbol after DONE.
}
const nextTask = new Task({
...this,
Expand Down

0 comments on commit 0495f5a

Please sign in to comment.