Repository navigation
Description
Summary
changePriority() in helpers/paragraph.js removes every ! in a task line, not just the leading priority marker. Since 2.6.0 added due dates (!YYYY-MM-DD / !>YYYY-MM-DD), this means changing a task's priority silently loses its due date. Related problems:
getTaskPriority()counts a due date as a priority.cyclePriorityStateDown()doesn't cycle from "no priority" to>>.>>without a following space can't be cycled.
Found while working on the Dashboard task dialog (#795). It's not changed there, because this is shared helper code.
What happens
Code: helpers/paragraph.js L907-L979
outputPara.content = outputPara.content.replace(/!\s*/g, '').replace(/\s+!/g, '').replace(/^>>\s/, '')I ran the current logic on some sample lines:
| Task text | getTaskPriority |
Cycle up → | Cycle down → |
|---|---|---|---|
Pay rent !>2026-12-05 |
1 ❌ (it's a due date) | !! Pay rent >2026-12-05 ❌ due becomes scheduled |
Pay rent >2026-12-05 ❌ |
Pay rent !2026-12-05 |
0 | ! Pay rent 2026-12-05 ❌ due date lost |
Pay rent 2026-12-05 ❌ |
Wow! Great news |
0 | ! WowGreat news ❌ text mangled |
WowGreat news ❌ |
See  here |
0 | ! See [chart](img.png) here ❌ image becomes a link |
See [chart](img.png) here ❌ |
>>Urgent no space |
4 | >>Urgent no space ❌ no change |
!!! >>Urgent no space ❌ |
Plain task |
0 | ! Plain task ✅ |
Plain task ❌ (doc says none → >>) |
!!! Top task |
3 | >> Top task ✅ |
!! Top task ✅ |
The worst case is the first row. !>date turns into >date, so a due date quietly becomes a scheduled date: the task moves to that day and stops showing as due or overdue. Nothing tells the user.
Causes
changePriority:/!\s*/gmatches any!anywhere, and also eats the space after it (Wow! Great→WowGreat).getTaskPriority:/\B\!+\B(?!\[)/matches the!of!>2026-…(!followed by>is a non-word boundary).cyclePriorityStateDown:(0 - 1) % 5is-1in JS, soPRIORITY_LEVELS[-1]isundefined→ no priority. It needs(level + 4) % 5.>>is only stripped when followed by a space (/^>>\s/), butgetTaskPriorityrecognises it without one.
The sorting/display priority has a related bug
Sorting, the Priority section, Wins counting and the Dashboard rows' priority styling all use a different function: getNumericPriority() / getNumericPriorityFromPara() in helpers/sorting.js. It reads only a leading run of ! (RE_LEADING_EXCLAMATIONS = /^\s*(!+)/). So a due date in the middle or at the end of a line is fine, but a due date at the start of the line counts as priority 1.
I checked by running the real functions through jest:
| Task text | getNumericPriority (sorting, sections, display) |
getTaskPriority (cycling) |
|---|---|---|
!>2026-12-05 Pay rent |
1 ❌ | 1 ❌ |
!2026-12-05 Pay rent |
1 ❌ | 0 |
Pay rent !>2026-12-05 |
0 ✅ | 1 ❌ |
! Pay rent !>2026-12-05 |
1 ✅ | 1 ✅ |
!Pay rent (no space) |
1 | 0 |
Pay rent !! (trailing) |
0 | 2 |
!!!! Four |
4 | 4 |
>>Urgent |
4 | 4 |
Effect in the Dashboard of a task that starts with a due date:
- It's treated as priority 1 by
dataGenerationPriority.jsandpriorityNoteIndexCache.js(getNumericPriorityFromPara(p) > 0), so it can show up in the Priority section. - It gets priority-1 styling on its row (
dashboardHelpers.jssetspriority:). - It counts as a Win when the Wins level is 1 (
countDoneTasks.js). - It's reported as priority 1 by
explainSelectedItemFilters.js. - It sorts by priority 1 anywhere
sortListBy(..., '-priority')is used.
The two functions also disagree with each other: trailing !!, ! without a space, and mid-line due dates are all read differently. So cycling starts from a different level than the one the Dashboard shows.
Where it's used
| Caller | What it does | Effect of the bug |
|---|---|---|
jgclark.Dashboard/src/clickHandlers.js → doCyclePriorityStateUp / doCyclePriorityStateDown (via cyclePriorityStateUp/Down) |
Priority ⬆/⬇ buttons in the Dashboard task dialog, including Interactive Processing | The most-used path. Any overdue or due task with a !>date loses its due date when its priority is bumped |
dwertheimer.TaskAutomations/src/NPTaskScanAndProcess.js → handlePriorityAction (calls changePriority directly) |
The priority choice in the "review overdue tasks" command bar flow | Same loss of due dates and ! in text. Note it also offers !!!! (__p4__), which isn't in PRIORITY_LEVELS |
There are no unit tests for getTaskPriority, changePriority or cyclePriorityState* today. removeTaskPriorityIndicators() (same file) already strips only from the start of the line, and could be the model for the fix.
Suggested fix
changePriority: strip only a leading marker (/^(!{1,3}|>>)\s*/), then prepend the new one. Leave!elsewhere alone. This matches how NotePlan itself writes priority (at the start of the line).- One definition of priority. Have the cycle functions use the same reading as sorting (
getNumericPriority), rather thangetTaskPriority's looser regex. Then the level you cycle from is the one the Dashboard shows. - Exclude due dates from the leading-
!match inRE_LEADING_EXCLAMATIONS(and anywhere else priority is read), e.g./^\s*(!+)(?!>?\d{4}-)/, so that!date/!>date/!>YYYY-Wnnat the start of a line isn't priority 1. The existinggetNumericPriority()tests inhelpers/__tests__/sorting.test.jsare the place to add these cases. cyclePriorityStateDown: use(level + 4) % 5.- Tests: add unit tests for all three, using the cases in the table above.
What changing it could affect
- Tasks with a priority marker mid-line. Today,
changePriorityremoves!!from anywhere (e.g.Call Bob !!) when it sets a new priority. Sorting already ignores a trailing!!(it reads only the start of the line). So a start-only strip would leave such markers in place, but it wouldn't change how anything is sorted or shown. - Changing
RE_LEADING_EXCLAMATIONSaffects every priority-based feature listed above (Priority section, priority note index, Wins, row styling, sorting). That's the intent: only tasks starting with a due date change, and they stop being treated as priority 1. The priority note index cache would need a rebuild to drop them. getTaskPriorityhas no other callers besidescyclePriorityStateUp/Down, so replacing it only changes which level cycling starts from.- TaskAutomations'
!!!!: sorting treats!!!!as priority 4 (the same level as>>), so it's legitimate. Strip!{1,4}, not!{1,3}. - Low risk otherwise: the change only narrows what gets removed. Lines without a priority or due date behave the same.
Activity
dwertheimer commentedon Dec 3, 2026
Claude's comment above mentions that NotePlan honors priority markers anywhere in the task but that is not correct. The priority has to be at the start of a line with whitespace behind it.
[-]changePriority() strips every '!' in a task, turning due dates into scheduled dates[/-][+]Priority helpers: changePriority() strips every '!' (due dates become scheduled), and a leading due date counts as priority 1[/+]jgclark commentedon Dec 3, 2026
Thanks for this clear issue description. I started working on this before you pushed the PR for this, unfortunately.
I'm incorporating this fix as 2.6.2, along with another change to priorities: matching Eduard's implied rule that a priority marker must also have whitespace after it. And I've opened #800 which I discovered as I was testing the fix here.