mirror of
https://github.com/neovim/neovim.git
synced 2026-11-06 05:16:52 +00:00
fix(options): vim.opt_local:remove({...}) ignored for flag lists #42001
Problem:
vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' }) silently does
nothing since f34ee3da.
Solution:
Join an Array with no separator for a bare flag list, matching the Dict
branch in optval_from_obj().
AI-assisted
This commit is contained in:
1 parent
32665c4549
commit
429338e74b
2 files changed
+18
-1
No files matched your search
+2
-1
@@ -3841,7 +3841,8 @@ Object optval_from_obj(OptIndex opt_idx, Object o, set_op_T op, bool *error)
|
||||
GA_APPEND(char *, &ga, xstrdup(item.data.string.data));
|
||||
}
|
||||
}
|
||||
str = ga_concat_strings(&ga, ",");
|
||||
// A bare flag list is concatenated with no separator, as in the Dict branch below.
|
||||
str = ga_concat_strings(&ga, (is_flaglist && !is_comma) ? "" : ",");
|
||||
GA_DEEP_CLEAR_PTR(&ga);
|
||||
} else { // kObjectTypeDict
|
||||
garray_T ga;
|
||||
|
||||
@@ -1057,6 +1057,14 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('removes flags from a set when calling remove with a table: #41953', function()
|
||||
eq_exec_lua({ j = true, q = true, l = true }, function()
|
||||
vim.opt.formatoptions = 'jcroql'
|
||||
vim.opt.formatoptions:remove { 'c', 'r', 'o' }
|
||||
return vim.opt.formatoptions:get()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('automatically sets when calling append', function()
|
||||
eq_exec_lua('foo,bar,baz,bing', function()
|
||||
vim.opt.wildignore = 'foo,bar,baz'
|
||||
@@ -1380,6 +1388,14 @@ describe('lua stdlib', function()
|
||||
return vim.bo.tags
|
||||
end)
|
||||
end)
|
||||
|
||||
it('removes a table of flags from a flag-list option: #41953', function()
|
||||
eq_exec_lua('jql', function()
|
||||
vim.opt_local.formatoptions = 'jcroql'
|
||||
vim.opt_local.formatoptions:remove { 'c', 'r', 'o' }
|
||||
return vim.bo.formatoptions
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.opt_global', function()
|
||||
|
||||
Reference in new issue
Block a user