aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2024-11-22 18:32:51 +0600
committerGitHub <noreply@github.com>2024-11-22 20:32:51 +0800
commitbff07f6dd0d8e58748f36670685dd6157a67976b (patch)
tree04bdefc7d7ebbd5613cee44bbe91aaf79ebb0b1a /test/functional/api/vim_spec.lua
parentc697c49a769794fdab0b8e77bb69d4435faa3d24 (diff)
downloadrneovim-bff07f6dd0d8e58748f36670685dd6157a67976b.tar.gz
rneovim-bff07f6dd0d8e58748f36670685dd6157a67976b.tar.bz2
rneovim-bff07f6dd0d8e58748f36670685dd6157a67976b.zip
fix(api): don't try to get/set option for invalid option name (#31302)
Problem: `validate_option_value_args()` returns `OK` even if option name is invalid or if option doesn't have the supported scope, which leads to Neovim still trying to erroneously get/set the option in those cases, which can lead to an assertion failure when `option_has_scope()` is invoked. This issue miraculously doesn't exist in release builds since the assertion is skipped and `(get/set)_option_value_for` returns if there is an error set, but that is not the intended location for that error to be caught. Solution: Make `validate_option_value_args()` return `FAIL` if there is an error set, which causes the API option functions to return early instead of trying to get/set an invalid option.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3f1e378bc1..2eeb5c18a1 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1770,6 +1770,11 @@ describe('API', function()
end)
it('validation', function()
+ eq("Unknown option 'foobar'", pcall_err(api.nvim_set_option_value, 'foobar', 'baz', {}))
+ eq(
+ "Unknown option 'foobar'",
+ pcall_err(api.nvim_set_option_value, 'foobar', 'baz', { win = api.nvim_get_current_win() })
+ )
eq(
"Invalid 'scope': expected 'local' or 'global'",
pcall_err(api.nvim_get_option_value, 'scrolloff', { scope = 'bogus' })