Skip to content

fix(priority): don't insert an empty [# ] cookie when clearing priority#1164

Open
liamrlawrence wants to merge 1 commit into
nvim-orgmode:masterfrom
liamrlawrence:fix/empty-priority-cookie
Open

fix(priority): don't insert an empty [# ] cookie when clearing priority#1164
liamrlawrence wants to merge 1 commit into
nvim-orgmode:masterfrom
liamrlawrence:fix/empty-priority-cookie

Conversation

@liamrlawrence

Copy link
Copy Markdown

Summary

  • Headline:set_priority only treated a blank priority as "remove the cookie"
    when a cookie already existed. The other branches ran when the headline had no
    cookie yet and always built a new one, even for a blank priority. As a result,
    pressing <Space> at the priority prompt on a headline with no existing cookie
    returned " " from PriorityState:prompt_user, fell through to an insertion
    branch, and produced a literal [# ] cookie instead of clearing the priority.

Changes

  • Move the empty-priority check to the top of set_priority so it applies to all
    paths: if the trimmed priority is empty, remove the existing cookie if present,
    otherwise do nothing. The insertion branches now only run with a real priority
    and can no longer fabricate an empty [# ] cookie.
  • Add a test covering <Space> on a headline without an existing priority.

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

Headline:set_priority only treated a blank priority as "remove the
cookie" when a cookie already existed. The other two branches ran when
the headline had no cookie yet. They always built a new cookie, even
when the priority was blank.

As a result, pressing <Space> at the priority prompt on a headline
without an existing cookie returned " " from PriorityState:prompt_user,
which fell through to an insertion branch and produced a literal
[# ] cookie instead of clearing the priority.

Bring the empty check to the top of set_priority so it applies to all
paths: if the trimmed priority is empty, remove the existing cookie if
present, otherwise do nothing. The insertion branches now only run with
a real priority and can no longer fabricate an empty cookie.
@liamrlawrence liamrlawrence force-pushed the fix/empty-priority-cookie branch from dcb3414 to 19e4218 Compare June 29, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant