Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dwertheimer.TaskAutomations/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

NOTE: A COUPLE OF RELEASES AFTER 3.0.0 DELETE THE SETTINGS THAT PERTAIN TO TASKS

## [3.2.2] @dwertheimer 2026-12-03

- Fix: In the overdue review, the "!!!! Set priority to p4" option is gone. NotePlan has no `!!!!` marker, so it wrote a line that NotePlan showed with no priority. Use ">> Set task as next up" for the highest priority.
- Fix: Setting or removing a priority no longer touches due dates (`!>2026-12-05`) or other `!` in the line, and only a leading `!`, `!!`, `!!!` or `>>` followed by a space counts as a priority (shared helpers, matching NotePlan).

## [3.2.1] @dwertheimer 2026-08-01

- Change: "Use simplified (re)scheduling method?" now defaults to **on**, so rescheduling an overdue item keeps the in-place behaviour it had before 3.2.0. NotePlan's normal scheduling method (mark the original `[>]` plus a back-linked copy in the destination calendar note) is now opt-in — turn the setting off to get it. 3.2.0 shipped this the other way round, which changed the default behaviour of the overdue review for everyone.
Expand Down
4 changes: 2 additions & 2 deletions dwertheimer.TaskAutomations/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"plugin.name": "✅ Overdue Task Processing",
"plugin.description": "Automations for handling Tasks:\n- Overdue/Forgotten task scanning\n- Task sorting within a note\n- Copying #tags/@mentions from one task to another\n- Mark all tasks in note open/completed\n- Automatically opening URLs of task lines",
"plugin.author": "@dwertheimer",
"plugin.version": "3.2.1",
"plugin.lastUpdateInfo": "Rescheduling an overdue item now keeps its previous in-place behaviour by default. Turn OFF 'Use simplified (re)scheduling method?' to opt in to NotePlan's normal scheduling method, where the original is marked '[>]' and a back-linked copy is added to the destination calendar note. Also: 'This week' and 'Next week' in the follow-up date picker now respect NotePlan's 'Start Week On' setting.",
"plugin.version": "3.2.2",
"plugin.lastUpdateInfo": "3.2.2: Priority changes keep due dates, and the '!!!!' option (not a NotePlan priority) is gone.\n3.2.1: Rescheduling an overdue item now keeps its previous in-place behaviour by default. Turn OFF 'Use simplified (re)scheduling method?' to opt in to NotePlan's normal scheduling method, where the original is marked '[>]' and a back-linked copy is added to the destination calendar note. Also: 'This week' and 'Next week' in the follow-up date picker now respect NotePlan's 'Start Week On' setting.",
"DELETE_ME": "DON'T DELETE commandMigrationMessage or offerToDownloadPlugin until they are documented somewhere",
"commandMigrationMessage": "NOTE: Task Sorting commands have been moved from the Task Automations plugin to the Task Sorting plugin. This plugin has been renamed to 'Overdue Task Processing'.",
"offerToDownloadPlugin": {
Expand Down
3 changes: 1 addition & 2 deletions dwertheimer.TaskAutomations/src/NPTaskScanAndProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export function getSingleTaskOptions(origPara: TParagraph, todayLines: any, cont
{ label: `! Set priority to p1`, value: '__p1__' },
{ label: `!! Set priority to p2`, value: '__p2__' },
{ label: `!!! Set priority to p3`, value: '__p3__' },
{ label: `!!!! Set priority to p4`, value: '__p4__' },
{ label: `x! Remove priority from task (p0)`, value: '__p0__' },
]
if (NotePlan.environment.platform === 'macOS') {
Expand Down Expand Up @@ -287,7 +286,7 @@ export function handlePriorityAction(origPara: TParagraph, userChoice: string):
__p1__: '!',
__p2__: '!!',
__p3__: '!!!',
__p4__: '!!!!',
__p4__: '>>', // NotePlan has no '!!!!' marker; '>>' is its highest priority
'__>>__': '>>',
}
const prioritySymbol = priorityMap[userChoice] || ''
Expand Down
10 changes: 3 additions & 7 deletions helpers/HTMLView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getFolderFromFilename } from '@helpers/folders'
import { clo, logDebug, logError, logInfo, logWarn, JSP, timer } from '@helpers/dev'
import { getStoredWindowRect, getWindowFromCustomId, isHTMLWindowOpen, storeWindowRect } from '@helpers/NPWindows'
import { generateCSSFromTheme, RGBColourConvert } from '@helpers/NPThemeToCSS'
import { isTermInEventLinkHiddenPart, isTermInNotelinkOrURI, isTermInMarkdownPath } from '@helpers/paragraph'
import { getTaskPriority, isTermInEventLinkHiddenPart, isTermInNotelinkOrURI, isTermInMarkdownPath } from '@helpers/paragraph'
import { RE_EVENT_LINK, RE_SYNC_MARKER } from '@helpers/regex'
import { getTimeBlockString, isTimeBlockLine } from '@helpers/timeblocks'
import { usersVersionHas } from '@helpers/NPVersions'
Expand Down Expand Up @@ -197,12 +197,8 @@ function taskStateFromBox(box: string, marker: string): string {
* @returns {string} `priority1`..`priority4`, or ''
*/
function priorityClassFromTaskText(text: string): string {
const match = text.match(/^(!!!|!!|!|>>)(?=\s|$)/)
if (!match) return ''
if (match[1] === '>>') return 'priority4'
if (match[1] === '!!!') return 'priority3'
if (match[1] === '!!') return 'priority2'
return 'priority1'
const level = getTaskPriority(text)
return level > 0 ? `priority${String(level)}` : ''
}

/**
Expand Down
14 changes: 10 additions & 4 deletions helpers/__tests__/paragraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,8 @@ describe('paragraph.js', () => {
['! Pay rent !>2026-12-05', 1],
['!Pay rent', 0],
['Pay rent !!', 0],
['!!!! Four', 4],
['!!!! Four', 0], // NotePlan has no '!!!!' marker
['!!!!! Five', 0],
['>>Urgent', 0],
['>> Urgent', 4],
['![chart](img.png) here', 0],
Expand Down Expand Up @@ -996,13 +997,18 @@ describe('paragraph.js', () => {
expect(p.changePriority(task('![chart](img.png) here'), '!')).toEqual('! ![chart](img.png) here')
})

test('replaces a leading marker that has whitespace after it, including !!!!', () => {
test('replaces a leading marker that has whitespace after it', () => {
expect(p.changePriority(task('!!! Top task'), '')).toEqual('Top task')
expect(p.changePriority(task('>>Urgent no space'), '!')).toEqual('! >>Urgent no space')
expect(p.changePriority(task('! Pay rent !>2026-12-05'), '!!!!')).toEqual('!!!! Pay rent !>2026-12-05')
expect(p.changePriority(task('! Pay rent !>2026-12-05'), '>>')).toEqual('>> Pay rent !>2026-12-05')
expect(p.changePriority(task('Pay rent !!'), '!')).toEqual('! Pay rent !!')
})

test("treats a marker NotePlan doesn't recognise ('!!!!') as no priority", () => {
expect(p.changePriority(task('! Pay rent'), '!!!!')).toEqual('Pay rent')
expect(p.changePriority(task('!!!! Four'), '')).toEqual('!!!! Four')
})

test('keeps indent and a task marker, and writes the new marker at the start of the main content', () => {
expect(p.changePriority(task('* ! Pay rent'), '!!')).toEqual('* !! Pay rent')
expect(p.changePriority(task(' - [ ] >> Pay rent'), '')).toEqual(' - [ ] Pay rent')
Expand All @@ -1027,7 +1033,7 @@ describe('paragraph.js', () => {
['! Pay rent !>2026-12-05', '!! Pay rent !>2026-12-05', 'Pay rent !>2026-12-05'],
['!Pay rent', '! !Pay rent', '>> !Pay rent'],
['Pay rent !!', '! Pay rent !!', '>> Pay rent !!'],
['!!!! Four', 'Four', '!!! Four'],
['!!!! Four', '! !!!! Four', '>> !!!! Four'],
['>>Urgent', '! >>Urgent', '>> >>Urgent'],
['* ! Pay rent', '* !! Pay rent', '* Pay rent'],
['\t- [ ] >> done', '\t- [ ] done', '\t- [ ] !!! done'],
Expand Down
3 changes: 2 additions & 1 deletion helpers/__tests__/sorting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ describe('sorting.js', () => {
['! Pay rent !>2026-12-05', 1],
['!Pay rent', 0],
['Pay rent !!', 0],
['!!!! Four', 4],
['!!!! Four', 0], // NotePlan has no '!!!!' marker
['!!!!! Five', 0],
['>>Urgent', 0],
['>> Urgent', 4],
['![chart](img.png) here', 0],
Expand Down
16 changes: 11 additions & 5 deletions helpers/paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ export function removeDuplicateSyncedLines(paras: $ReadOnlyArray<TParagraph>): $
}

/**
* Return numeric Priority of a task from a marker at the start of the main content (`!`, `!!`, `!!!`, `!!!!`, `>>`).
* Return numeric Priority of a task from a marker at the start of the main content (`!`, `!!`, `!!!`, `>>`).
* Whitespace has to follow the marker. Indent and a task marker before that are ignored.
* `>>` is priority 4. No priority is 0.
* Same reading as sorting's getNumericPriority for these markers (see getLeadingPriorityMarkerLevel).
Expand All @@ -923,25 +923,31 @@ export function removeTaskPriorityIndicators(content: string): string {
// Leading marker only, and only with whitespace after it. `!` / `>>` anywhere else
// (a due date, "Wow!", an image, `>>Urgent`) stays. Indent and a task marker in front stay too.

// NotePlan's priority markers, indexed by level (0 = none)
const PRIORITY_LEVELS = ['', '!', '!!', '!!!', '>>']

/**
* Change the priority in a task to '!', '!!', '!!!', '>>' (or remove priority)
* @author @dwertheimer updated by @jgclark
* @param {TParagraph} input - the task/pagraph to be processed
* @param {string} priorityString - the new priority (!,!!,!!!,!!!! or '' for none)
* @param {string} priorityString - the new priority ('!', '!!', '!!!', '>>', or '' for none). Anything else (e.g. '!!!!', which NotePlan doesn't recognise) removes the priority.
* @param {boolean} - commit the change after the change is made (default false)
* @returns {string} the resulting updated paragraph's content
* Note: If the third param is missing or false, THE CHANGE HAS NOT BEEN COMMITTED YET. You should use note.updateParagraph(s) to commit the change you receive back.
* Note: Ideally lives in NPParagraph.js, but putting it here avoids a circular dependency
*/
export function changePriority(inputPara: TParagraph, prioStr: string, commitChange?: boolean = false): string {
const outputPara = inputPara
outputPara.content = setLeadingPriorityMarker(outputPara.content, prioStr)
let marker = prioStr
if (!PRIORITY_LEVELS.includes(marker)) {
logWarn('changePriority', `'${prioStr}' is not a NotePlan priority marker, so removing the priority instead`)
marker = ''
}
outputPara.content = setLeadingPriorityMarker(outputPara.content, marker)
commitChange && outputPara.note ? outputPara.note.updateParagraph(outputPara) : null
return outputPara.content
}

const PRIORITY_LEVELS = ['', '!', '!!', '!!!', '>>']

/**
* Level to cycle from. Uses the same reading as sorting in the Dashboard (getNumericPriority).
* Empty content is -1 there; treat that as "no priority" (0).
Expand Down
11 changes: 6 additions & 5 deletions helpers/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ const RE_HASHTAGS: RegExp = /\B(?:#|#)((?![\p{N}\-_\/]+(?:$|[^\p{L}\p{M}\p{N}\
// Mentions follow the same rule. NotePlan reports "@estimate(2)" as the mention "@estimate", so the
// trailing "(...)" is left out here too -- which also keeps @estimate(2) and @estimate(5) in one sort group.
const RE_MENTIONS: RegExp = /\B@((?![\p{N}\-_\/]+(?:$|[^\p{L}\p{M}\p{N}\p{S}\-_\/]))[\p{L}\p{M}\p{N}\p{S}\-_\/]{0,59}[\p{L}\p{M}\p{N}\p{S}\-_])/gu
// '!' at the start of the main content only, and only when whitespace follows it.
// '!', '!!' or '!!!' at the start of the main content only, and only when whitespace follows it.
// NotePlan has no '!!!!' marker, so a run of four or more '!' is not a priority.
// That excludes !>dates, !dates, and ![](image) links. Indent is allowed before the marker.
// Apply this to the main content (see mainContentOfLine), not to a raw line that still has its task marker.
// See getLeadingPriorityMarkerLevel(). RE_STRIP_LEADING_PRIORITY and RE_INDENT_AND_TASK_PREFIX are built from this.
const RE_LEADING_EXCLAMATIONS: RegExp = /^\s*(!+)(?!>?\d{4}-)(?!\[)(?=\s)/g
// `(!+)(?!>?\d{4}-)(?!\[)` — RE_LEADING_EXCLAMATIONS without its leading indent or its trailing space lookahead.
const RE_LEADING_EXCLAMATIONS: RegExp = /^\s*(!{1,3})(?!>?\d{4}-)(?!\[)(?=\s)/g
// `(!{1,3})(?!>?\d{4}-)(?!\[)` — RE_LEADING_EXCLAMATIONS without its leading indent or its trailing space lookahead.
const LEADING_EXCLAMATION_MARKER: string = RE_LEADING_EXCLAMATIONS.source.replace(/^\^\\s\*/, '').replace(/\(\?=\\s\)$/, '')
// The `\s*` indent RE_LEADING_EXCLAMATIONS allows before '!'.
const LEADING_INDENT: string = (RE_LEADING_EXCLAMATIONS.source.match(/^\^(\\s\*)/) || ['', '\\s*'])[1]
Expand Down Expand Up @@ -224,7 +225,7 @@ export function mainContentOfLine(content: string): string {
}

/**
* Priority from a marker at the start of the main content: `!` / `!!` / `!!!` / `!!!!` / `>>`.
* Priority from a marker at the start of the main content: `!` / `!!` / `!!!` / `>>` (NotePlan has no `!!!!`).
* Whitespace has to follow the marker. A due date, an image, or `!` / `>>` glued to the next word is 0.
* Indent and a task marker before the main content are ignored. This is the same reading
* getNumericPriority uses for `!` and `>>` (not `(A)` / `(W)` parens).
Expand Down Expand Up @@ -257,7 +258,7 @@ export function stripLeadingPriorityMarker(content: string): string {
* Replace the leading priority marker, writing `prioStr` at the start of the main content.
* An empty `prioStr` only removes the marker. Indent and a task marker stay in front.
* @param {string} content
* @param {string} prioStr `!`, `!!`, `!!!`, `>>`, `!!!!`, or `''`
* @param {string} prioStr `!`, `!!`, `!!!`, `>>`, or `''`
* @returns {string}
*/
export function setLeadingPriorityMarker(content: string, prioStr: string): string {
Expand Down
Loading