From 9c8a2b8a1712fd1aca73bb33a4427a68490c5978 Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Tue, 29 Oct 2024 09:22:30 +0200 Subject: [PATCH] Update bestTask() to select CERTs with priority --- src/Worktodo.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Worktodo.cpp b/src/Worktodo.cpp index bba33809..bc3e4d82 100644 --- a/src/Worktodo.cpp +++ b/src/Worktodo.cpp @@ -92,12 +92,16 @@ std::optional parse(const std::string& line) { return {}; } -// Among the valid tasks from fileName, return the "best" which means with the smallest exponent +// Among the valid tasks from fileName, return the "best" which means the smallest CERT, or otherwise the exponent PRP/LL static std::optional bestTask(const fs::path& fileName) { optional best; for (const string& line : File::openRead(fileName)) { optional task = parse(line); - if (task && (!best || task->exponent < best->exponent)) { best = task; } + if (task && (!best + || (best->kind != Task::CERT && task->kind == Task::CERT) + || ((best->kind != Task::CERT || task->kind == Task::CERT) && task->exponent < best->exponent))) { + best = task; + } } return best; }