Skip to content
Open
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
6 changes: 5 additions & 1 deletion lua/orgmode/objects/priority_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/plenary/ui/mappings/priority_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)