From 54ecfc7c245e5e3fbbc749658ad171335418d48c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 12:28:05 +0200 Subject: [PATCH] fix(help): sort readme tags case sensitive. Fixes #67 --- lua/lazy/help.lua | 2 +- lua/lazy/util.lua | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/lazy/help.lua b/lua/lazy/help.lua index 4a289eb..a33e808 100644 --- a/lua/lazy/help.lua +++ b/lua/lazy/help.lua @@ -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 diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua index dbe108b..d841255 100644 --- a/lua/lazy/util.lua +++ b/lua/lazy/util.lua @@ -235,10 +235,14 @@ end ---@generic V ---@param t table ---@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