From 6257270040bc5c61a489f7fb9d4102223c36cf89 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Fri, 8 Nov 2024 11:57:59 +0600 Subject: 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. --- test/functional/lua/with_spec.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'test/functional/lua') diff --git a/test/functional/lua/with_spec.lua b/test/functional/lua/with_spec.lua index 92e798e7f3..a68a7722a4 100644 --- a/test/functional/lua/with_spec.lua +++ b/test/functional/lua/with_spec.lua @@ -882,11 +882,7 @@ describe('vim._with', function() eq({ bo = { cms_cur = '// %s', cms_other = '-- %s', ul_cur = 250, ul_other = -123456 }, wo = { ve_cur = 'insert', ve_other = 'block', winbl_cur = 25, winbl_other = 10 }, - -- Global `winbl` inside context ideally should be untouched and equal - -- to 50. It seems to be equal to 0 because `context.buf` uses - -- `aucmd_prepbuf` C approach which has no guarantees about window or - -- window option values inside context. - go = { cms = '-- %s', ul = 0, ve = 'none', winbl = 0, lmap = 'xy,yx' }, + go = { cms = '-- %s', ul = 0, ve = 'none', winbl = 50, lmap = 'xy,yx' }, }, out.inner) eq(out.before, out.after) end) -- cgit