aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-09-22 14:59:56 -0600
committerJosh Rahm <rahm@google.com>2021-10-05 02:21:59 -0600
commitba1e9454aacd27582d1d4c5b5153bd175a16c461 (patch)
treeb3681474f076fffc7d7d948f16cd91369a69babc
parent264c6c463811f45c2a66e0ac948c49657c57b3ac (diff)
downloadrneovim-ba1e9454aacd27582d1d4c5b5153bd175a16c461.tar.gz
rneovim-ba1e9454aacd27582d1d4c5b5153bd175a16c461.tar.bz2
rneovim-ba1e9454aacd27582d1d4c5b5153bd175a16c461.zip
Add a check to the gen_options.lua script to ensure the options are well ordered.
(Neo)Vim uses a jump table based on the first character of the option's name. This means for it to work all options with the same first character must be together. If this is violated, some options may seem to disappear, which can sometimes happen during merges if not careful. This commit adds a check to the gen_options.lua script so the build will fail if this constraint is violated.
-rw-r--r--src/nvim/generators/gen_options.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index 0454c54faf..51ffdae3b0 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -183,6 +183,26 @@ local dump_option = function(i, o)
w(' },')
end
+-- Verify options are correctly ordered. The options with the same first letter
+-- must be together or else some of the options may seem to disappear from
+-- Neovim.
+done_chrs = {}
+last_opt = nil
+for _, o in ipairs(options.options) do
+ if (last_opt == nil) then
+ last_opt = o
+ elseif last_opt.full_name:sub(1, 1) ~= o.full_name:sub(1, 1) then
+ done_chrs[last_opt.full_name:sub(1, 1)] = true
+ last_opt = o
+
+ if done_chrs[o.full_name:sub(1, 1)] then
+ print("Option '" .. o.full_name .. "' must be next to options with the "
+ .. "same starting character.")
+ os.exit(1)
+ end
+ end
+end
+
w('static vimoption_T options[] = {')
for i, o in ipairs(options.options) do
dump_option(i, o)