diff options
author | Josh Rahm <rahm@google.com> | 2021-09-22 14:59:56 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-01-11 14:12:29 -0700 |
commit | a3ce4403c6ec97fdadb92e4ffc7ea65bf797112c (patch) | |
tree | 8238b2b7bf46b5d2824224d4383633537fcec560 | |
parent | 13c2be90350e0cab0cdc92c0614f42b93220be85 (diff) | |
download | rneovim-a3ce4403c6ec97fdadb92e4ffc7ea65bf797112c.tar.gz rneovim-a3ce4403c6ec97fdadb92e4ffc7ea65bf797112c.tar.bz2 rneovim-a3ce4403c6ec97fdadb92e4ffc7ea65bf797112c.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.lua | 20 |
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) |