Skip to content

Commit

Permalink
fix(help): sort readme tags case sensitive. Fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Sep 28, 2023
1 parent 4f27fc3 commit 54ecfc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/lazy/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function M.update()
local lines = { [[!_TAG_FILE_ENCODING utf-8 //]] }
Util.foreach(tags, function(_, tag)
table.insert(lines, ("%s\t%s\t/%s"):format(tag.tag, tag.file, tag.line))
end)
end, { case_sensitive = true })
Util.write_file(docs .. "/tags", table.concat(lines, "\n"))
end

Expand Down
6 changes: 5 additions & 1 deletion lua/lazy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,14 @@ end
---@generic V
---@param t table<string, V>
---@param fn fun(key:string, value:V)
function M.foreach(t, fn)
---@param opts? {case_sensitive?:boolean}
function M.foreach(t, fn, opts)
---@type string[]
local keys = vim.tbl_keys(t)
pcall(table.sort, keys, function(a, b)
if opts and opts.case_sensitive then
return a < b
end
return a:lower() < b:lower()
end)
for _, key in ipairs(keys) do
Expand Down

0 comments on commit 54ecfc7

Please sign in to comment.