Skip to content

Commit

Permalink
fix(tags): Do not sort tags in tags change prompt
Browse files Browse the repository at this point in the history
Fixes #866
  • Loading branch information
kristijanhusak committed Jan 21, 2025
1 parent c889000 commit 42a4ccf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lua/orgmode/org/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ end
---@param tags? string|string[]
function OrgMappings:set_tags(tags)
local headline = self.files:get_closest_headline()
local current_tags = utils.tags_to_string(headline:get_own_tags())
local headline_tags = headline:get_own_tags()
local current_tags = utils.tags_to_string(headline_tags)

if not tags then
tags = utils.input('Tags: ', current_tags, function(arg_lead)
Expand Down
6 changes: 4 additions & 2 deletions lua/orgmode/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,13 @@ end

function utils.tags_to_string(taglist, sorted)
local tags = ''
local tags_list = taglist
if #taglist > 0 then
if sorted then
table.sort(taglist)
tags_list = vim.deepcopy(taglist)
table.sort(tags_list)
end
tags = ':' .. table.concat(taglist, ':') .. ':'
tags = ':' .. table.concat(tags_list, ':') .. ':'
end
return tags
end
Expand Down

0 comments on commit 42a4ccf

Please sign in to comment.