Repository navigation
Priority markers follow NotePlan's rule (fixes due dates lost on priority change) - #797
Closed
dwertheimer wants to merge 1 commit into
Closed
dwertheimer wants to merge 1 commit into
dwertheimer wants to merge 1 commit into
Conversation
…lowed by a space
- New helpers/taskPriority.js (no imports): the single definition of what counts
as a priority marker, plus get/remove/set/next-level helpers.
- paragraph.js: getTaskPriority, removeTaskPriorityIndicators, changePriority and
cyclePriorityStateUp/Down use it. changePriority no longer strips every '!'
in the line (which turned '!>date' due dates into '>date' scheduled dates and
mangled 'Wow!' and images). Cycling down from none now goes to '>>'.
- sorting.js: getNumericPriority no longer counts '!!!!', '!x' (no space) or a
leading due date ('!>2026-12-05 ...') as a priority; '>>' needs a space too.
- HTMLView.js: preview priority styling uses the same rule.
- TaskAutomations: drop the '!!!!' (p4) option, which isn't a NotePlan
priority; '__p4__' now writes '>>'.
Closes #796
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #796.
Why
NotePlan only treats a priority marker as one when it's at the start of the task's text and followed by a space:
!,!!,!!!or>>. Our shared helpers each had their own, looser idea of this, and they disagreed with each other:changePriority()removed every!in the line. So changing a task's priority (Dashboard ⬆/⬇ buttons, TaskAutomations overdue review) did three kinds of damage:!>2026-12-05into the scheduled date>2026-12-05, silently. The task moved to that day and stopped showing as due or overdue.Wow! Great→WowGreat.into links.!!!! x,!x(no space), and a task that starts with a due date (!>2026-12-05 Pay rent= priority 1). That put such tasks in the Dashboard's Priority section, counted them as Wins, and styled them as priority 1.getTaskPriority). It found!anywhere in the line, including a due date's!, so the level cycling started from could differ from the level the Dashboard showed. Cycling down from no priority also stayed at none, because-1 % 5is-1in JS.What changed
helpers/taskPriority.jsis the single definition of a priority marker. It hasgetPriorityMarker,getPriorityLevel,removePriorityMarker,setPriorityLevelandnextPriorityLevel. It has no imports, so any helper or React code can use it. It isn't inparagraph.js, becauseparagraph.jsalready imports fromsorting.jsand that would create a cycle.helpers/paragraph.js:getTaskPriority,removeTaskPriorityIndicators,changePriorityandcyclePriorityStateUp/Downall use it.changePrioritynow replaces only the leading marker. Everything else in the line is left alone.>>, as its doc comment always said.changePriorityis given a string that isn't a NotePlan marker (e.g.!!!!), it logs a warning and removes the priority.helpers/sorting.js: ingetNumericPriority, the!markers now need a space after them (/^\s*(!{1,3})\s/), and>>follows the same rule. Todo.txt-style(A)/(B)/(W)priorities are unchanged; they're a TaskSorting feature, not a NotePlan marker.helpers/HTMLView.js: priority styling in rendered notes uses the same rule. Before, it also accepted a marker at the end of the line.!!!!Set priority to p4" option, since!!!!isn't a NotePlan priority. NotePlan's level 4 is>>, which already has its own option. A saved__p4__choice still works and now writes>>.Already correct, so left alone: the Dashboard's "hide priority markers" setting, the Reminders priority reader (
NPReminders.parseLeadingPriorityFromReminderText),NPParagraph.buildOpenTaskRawContentFromParts, and every place in other plugins that writes a marker. All of them write the marker followed by a space.Behaviour changes users may notice (all intended)
Pay rent !>2026-12-05, priority ⬆! Pay rent >2026-12-05(due date lost)! Pay rent !>2026-12-05!>2026-12-05 Pay rent!!!! Four>>)!Urgent(no space)Wow! Great, priority ⬆! WowGreat! Wow! Great>>The Dashboard's priority note index cache only drops tasks that start with a due date once it's rebuilt.
The helpers are bundled into each plugin at build time, so only plugins rebuilt from this commit get the fix. I traced every caller of the changed functions, directly and through
getTasksByType()andgetNoteContentAsHTML(). These plugins' behaviour changes:cyclePriorityStateUp/Down(clickHandlers.js);getNumericPriorityFromPara(dataGenerationPriority.js,priorityNoteIndexCache.js,countDoneTasks.js,dashboardHelpers.js,explainSelectedItemFilters.js)changePriority(NPTaskScanAndProcess.js, overdue review);getTasksByType(taskSync.js)!!!!option is gone.getTasksByType(sortTasks.js)getTasksByType(NPTimeblocking.js)getNoteContentAsHTML(previewMain.js)getNoteContentAsHTML(requestHandlers.js, markdown preview fields)getNoteContentAsHTML(requestHandlers.js)No other plugin calls these functions. Other plugins can pick this up whenever they're next rebuilt; nothing else changes for them.
This doesn't bump any plugin versions or changelogs, so each owner can fold it into their next release. The Dashboard task-dialog PR (#795) touches the same priority buttons, but neither PR depends on the other.
Tests
helpers/__tests__/taskPriority.test.js, plus new cases inparagraph.test.jsandsorting.test.js: 42 new tests.mainalready has, and no errors.🤖 Generated with Claude Code