From 2c79d7cb144404c480f1539d45f84787c43df0e9 Mon Sep 17 00:00:00 2001 From: lyz Date: Wed, 25 Feb 2026 11:06:19 +0100 Subject: [PATCH] fix: respect priority case --- lua/orgmode/objects/priority_state.lua | 6 +++++- tests/plenary/ui/mappings/priority_spec.lua | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/orgmode/objects/priority_state.lua b/lua/orgmode/objects/priority_state.lua index ef60d452a..bbabf9d56 100644 --- a/lua/orgmode/objects/priority_state.lua +++ b/lua/orgmode/objects/priority_state.lua @@ -35,7 +35,11 @@ function PriorityState:prompt_user() return nil end - choice = string.upper(choice) + if self.high_priority:match('%u') then + choice = string.upper(choice) + elseif self.high_priority:match('%l') then + choice = string.lower(choice) + end if #choice > 1 and tonumber(choice) == nil then utils.echo_warning(string.format('Only numeric priorities can be multiple characters long')) return nil diff --git a/tests/plenary/ui/mappings/priority_spec.lua b/tests/plenary/ui/mappings/priority_spec.lua index 18e300d3b..4a669590b 100644 --- a/tests/plenary/ui/mappings/priority_spec.lua +++ b/tests/plenary/ui/mappings/priority_spec.lua @@ -18,6 +18,14 @@ describe('Priority mappings', function() }) end + local lowercase_config = function() + config:extend({ + org_priority_highest = 'a', + org_priority_default = 'b', + org_priority_lowest = 'c', + }) + end + after_each(function() vim.cmd([[silent! %bw!]]) end) @@ -125,4 +133,15 @@ describe('Priority mappings', function() vim.cmd('norm ciR') assert.are.same('* [#9] Test orgmode', vim.fn.getline(1)) end) + + it('should set the priority based on the input key when using lowercase priorities', function() + lowercase_config() + helpers.create_file({ + '* TODO [#b] Test orgmode', + }) + vim.fn.cursor(1, 1) + assert.are.same('* TODO [#b] Test orgmode', vim.fn.getline(1)) + vim.cmd('norm ,o,a\r') + assert.are.same('* TODO [#a] Test orgmode', vim.fn.getline(1)) + end) end)