aboutsummaryrefslogtreecommitdiff
path: root/src/gen
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-10 08:27:30 +0800
committerGitHub <noreply@github.com>2025-03-10 00:27:30 +0000
commitc53e00889d38d19ec5e40f97e77280c8d4e33802 (patch)
tree8fe0677788952c210020fcc436b6f53467ffcd79 /src/gen
parentb90f649ca2e240c1bfb22fe91247bc90314af1e1 (diff)
downloadrneovim-c53e00889d38d19ec5e40f97e77280c8d4e33802.tar.gz
rneovim-c53e00889d38d19ec5e40f97e77280c8d4e33802.tar.bz2
rneovim-c53e00889d38d19ec5e40f97e77280c8d4e33802.zip
refactor(gen_events): sort enums case-insensitively (#32811)
This actually only affects the order in which Cmdline* and Cmdwin* autocommands are listed, and it appears that the names of Cmdwin* were changed to CmdWin* in 8ed2dbf6e2802516501c11e72e5d6d977e6a07f3 without explanation. Also, remove the final NULL element from the names table.
Diffstat (limited to 'src/gen')
-rw-r--r--src/gen/gen_events.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gen/gen_events.lua b/src/gen/gen_events.lua
index 23ca81b684..c6d97405af 100644
--- a/src/gen/gen_events.lua
+++ b/src/gen/gen_events.lua
@@ -8,7 +8,9 @@ local aliases = auevents.aliases
--- @type string[]
local names = vim.tbl_keys(vim.tbl_extend('error', events, aliases))
-table.sort(names)
+table.sort(names, function(a, b)
+ return a:lower() < b:lower()
+end)
local enum_tgt = assert(io.open(fileio_enum_file, 'w'))
local names_tgt = assert(io.open(names_file, 'w'))
@@ -22,7 +24,7 @@ static const struct event_name {
size_t len;
char *name;
int event;
-} event_names[] = {]])
+} event_names[NUM_EVENTS] = {]])
for i, name in ipairs(names) do
enum_tgt:write(('\n EVENT_%s = %u,'):format(name:upper(), i - 1))
@@ -45,11 +47,10 @@ enum_tgt:write(('\n NUM_EVENTS = %u,'):format(#names))
enum_tgt:write('\n} event_T;\n')
enum_tgt:close()
-names_tgt:write('\n [NUM_EVENTS] = {0, NULL, (event_T)0},\n};\n')
+names_tgt:write('\n};\n')
names_tgt:write('\nstatic AutoCmdVec autocmds[NUM_EVENTS] = { 0 };\n')
local hashorder = vim.tbl_map(string.lower, names)
-table.sort(hashorder)
local hashfun
hashorder, hashfun = hashy.hashy_hash('event_name2nr', hashorder, function(idx)
return 'event_names[event_hash[' .. idx .. ']].name'