From f663243e95f488b8f4224bdae2697ddac21d0ffb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 22 Oct 2024 09:05:14 +0800 Subject: vim-patch:9.1.0797: testing of options can be further improved (#30893) Problem: testing of options can be further improved Solution: split the generated option test into test_options_all.vim, add more test cases, save and restore values, fix use-after-free closes: vim/vim#15894 https://github.com/vim/vim/commit/6eca04e9f1d446dc509ba51e32da56fa413fe2f0 Co-authored-by: Milly --- scripts/gen_eval_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/gen_eval_files.lua') diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index b9ea4e73f0..eb92e10401 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -670,7 +670,7 @@ local function scope_to_doc(s) return m[s[1]] end assert(s[1] == 'global') - return 'global or ' .. m[s[2]] .. ' |global-local|' + return 'global or ' .. m[s[2]] .. (s[2] ~= 'tab' and ' |global-local|' or '') end -- @param o vim.option_meta -- cgit From 07b4cb6ada2da108bbf8277bec63068234ceaa67 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 22 Oct 2024 22:14:01 +0600 Subject: docs(options): remove description for hidden options #30903 Problem: Hidden options are documented despite being no-ops. Solution: Remove docs for hidden options. Move tags for options that we plan to restore, to ":help nvim-missing". Move tags for permanently removed options, to ":help nvim-removed". --- scripts/gen_eval_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/gen_eval_files.lua') diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index eb92e10401..2928361695 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -717,7 +717,7 @@ local function get_option_meta() local optinfo = vim.api.nvim_get_all_options_info() local ret = {} --- @type table for _, o in ipairs(opts) do - if o.desc then + if not o.immutable and not o.hidden and o.enable_if ~= false and o.desc then if o.full_name == 'cmdheight' then table.insert(o.scope, 'tab') end -- cgit From a27419f3fc540f66567f4559a796cd6758f1bb1f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 4 Nov 2024 19:00:12 +0600 Subject: feat(options)!: disallow setting hidden options #28400 Problem: There are three different ways of marking an option as hidden, `enable_if = false`, `hidden = true` and `immutable = true`. These also have different behaviors. Options hidden with `enable_if = false` can't have their value fetched using Vim script or the API, but options hidden with `hidden = true` or `immutable = true` can. On the other hand, options with `hidden = true` do not error when trying to set their value, but options with `immutable = true` do. Solution: Remove `enable_if = false`, remove the `hidden` property for options, and use `immutable = true` to mark an option as hidden instead. Also make hidden option variable pointers always point to the default value, which allows fetching the value of every hidden option using Vim script and the API. This does also mean that trying to set a hidden option will now give an error instead of just being ignored. --- scripts/gen_eval_files.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/gen_eval_files.lua') diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index 2928361695..edf95043c5 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -717,7 +717,9 @@ local function get_option_meta() local optinfo = vim.api.nvim_get_all_options_info() local ret = {} --- @type table for _, o in ipairs(opts) do - if not o.immutable and not o.hidden and o.enable_if ~= false and o.desc then + local is_window_option = #o.scope == 1 and o.scope[1] == 'window' + local is_option_hidden = o.immutable and not o.varname and not is_window_option + if not is_option_hidden and o.desc then if o.full_name == 'cmdheight' then table.insert(o.scope, 'tab') end -- cgit From 29ded889579a9d590e8ea885a9a402ff4bae87be Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sun, 17 Nov 2024 02:56:16 +0600 Subject: refactor(options): remove `.indir`, redesign option scopes #31066 Problem: The way option scopes currently work is inflexible and does not allow for nested option scopes or easily finding the value of an option at any arbitrary scope without having to do long handwritten switch-case statements like in `get_varp()`. `.indir` is also confusing and redundant since option indices for each scope can be autogenerated. Solution: Expand option scopes in such a way that an option can support any amount of scopes using a set of scope flags, similarly to how it's already done for option types. Also make options contain information about its index at each scope it supports. This allows for massively simplifying `get_varp()` and `get_varp_scope()` in the future by just using a struct for options at each scope. This would be done by creating a table that stores the offset of an option's variable at a scope by using the option's index at that scope as a key. This PR also autogenerates enums for option indices at each scope to remove the need for `.indir` entirely, and also to allow easily iterating over options all options that support any scope. Ref: #29314 --- scripts/gen_eval_files.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts/gen_eval_files.lua') diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index edf95043c5..a9431ae2e5 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -617,8 +617,8 @@ local function render_option_meta(_f, opt, write) end for _, s in pairs { - { 'wo', 'window' }, - { 'bo', 'buffer' }, + { 'wo', 'win' }, + { 'bo', 'buf' }, { 'go', 'global' }, } do local id, scope = s[1], s[2] @@ -661,8 +661,8 @@ end local function scope_to_doc(s) local m = { global = 'global', - buffer = 'local to buffer', - window = 'local to window', + buf = 'local to buffer', + win = 'local to window', tab = 'local to tab page', } @@ -717,7 +717,7 @@ local function get_option_meta() local optinfo = vim.api.nvim_get_all_options_info() local ret = {} --- @type table for _, o in ipairs(opts) do - local is_window_option = #o.scope == 1 and o.scope[1] == 'window' + local is_window_option = #o.scope == 1 and o.scope[1] == 'win' local is_option_hidden = o.immutable and not o.varname and not is_window_option if not is_option_hidden and o.desc then if o.full_name == 'cmdheight' then -- cgit