diff options
author | Famiu Haque <famiuhaque@proton.me> | 2024-11-08 11:57:59 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@proton.me> | 2024-12-26 20:55:13 +0600 |
commit | 6257270040bc5c61a489f7fb9d4102223c36cf89 (patch) | |
tree | a0db9a3bf31b56dedd9a240b54c5d47b02ce43ff /src/nvim/api/vim.c | |
parent | 98763ce4e93752f22d379e3f735f4c78ae49afad (diff) | |
download | rneovim-6257270040bc5c61a489f7fb9d4102223c36cf89.tar.gz rneovim-6257270040bc5c61a489f7fb9d4102223c36cf89.tar.bz2 rneovim-6257270040bc5c61a489f7fb9d4102223c36cf89.zip |
refactor(options): set option value for non-current context directly
Problem: Currently, we use `switch_option_context` to temporarily switch the current option context before setting an option for a different buffer / window. This is not ideal because we already support getting and setting option values for non-current contexts in the underlying implementation.
Solution: Set option value for non-current context by passing the context directly to the lower level functions. Also introduce a new `OptCtx` struct to store option context information, this will scale much better if we add more option scopes and other context information in the future.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 25f44bb4eb..108d1ee98d 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -982,10 +982,10 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err) buf_copy_options(buf, BCO_ENTER | BCO_NOHELP); if (scratch) { - set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL, 0, - kOptScopeBuf, buf); - set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL, 0, - kOptScopeBuf, buf); + set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), + option_ctx_from(kOptScopeBuf, buf), OPT_LOCAL, 0); + set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), + option_ctx_from(kOptScopeBuf, buf), OPT_LOCAL, 0); assert(buf->b_ml.ml_mfp->mf_fd < 0); // ml_open() should not have opened swapfile already buf->b_p_swf = false; buf->b_p_ml = false; |