From b56aa80a264f64776bccd8757909cf7f220e6cb8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 13 Oct 2024 08:09:53 +0800 Subject: vim-patch:9.1.0775: tests: not enough tests for setting options (#30785) Problem: tests: not enough tests for setting options Solution: Add more comprehensive tests to test_options (Milly). closes: vim/vim#15856 https://github.com/vim/vim/commit/484facebe4a0fb775ad011a99ba007f55fc4f11a Restore behavior of &l:option for unset local boolean options that was accidentally changed in #26429. Co-authored-by: Milly --- src/nvim/eval/vars.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index a33636667e..d002bff321 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1965,14 +1965,12 @@ typval_T optval_as_tv(OptVal value, bool numbool) case kOptValTypeNil: break; case kOptValTypeBoolean: - if (value.data.boolean != kNone) { - if (numbool) { - rettv.v_type = VAR_NUMBER; - rettv.vval.v_number = value.data.boolean == kTrue; - } else { - rettv.v_type = VAR_BOOL; - rettv.vval.v_bool = value.data.boolean == kTrue; - } + if (numbool) { + rettv.v_type = VAR_NUMBER; + rettv.vval.v_number = value.data.boolean; + } else if (value.data.boolean != kNone) { + rettv.v_type = VAR_BOOL; + rettv.vval.v_bool = value.data.boolean == kTrue; } break; // return v:null for None boolean value. case kOptValTypeNumber: -- cgit From 34c44c355646311aa67fe53e1e5ce040789430c6 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 28 Oct 2024 19:49:16 +0600 Subject: refactor(options): option flags enum #30961 Problem: Currently we use macros with hardcoded flag values for option flags, which is messy and requires a lot of mental math for adding / removing option flags. Using macros for option flags also means that they cannot be used inside debuggers. Solution: Create a new `OptFlags` enum that stores all the option flags in an organized way that is easier to understand. --- src/nvim/eval/vars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index d002bff321..d3f836f7f4 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1908,7 +1908,7 @@ static OptVal tv_to_optval(typval_T *tv, OptIndex opt_idx, const char *option, b const bool option_has_num = !is_tty_opt && option_has_type(opt_idx, kOptValTypeNumber); const bool option_has_str = is_tty_opt || option_has_type(opt_idx, kOptValTypeString); - if (!is_tty_opt && (get_option(opt_idx)->flags & P_FUNC) && tv_is_func(*tv)) { + if (!is_tty_opt && (get_option(opt_idx)->flags & kOptFlagFunc) && tv_is_func(*tv)) { // If the option can be set to a function reference or a lambda // and the passed value is a function reference, then convert it to // the name (string) of the function reference. -- cgit From 05d9e6a9e850ee797a4a018e72156dd62831a4b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 30 Oct 2024 09:05:11 +0800 Subject: vim-patch:9.1.0822: topline might be changed in diff mode unexpectedly (#30988) Problem: topline might be changed in diff mode unexpectedly (Jaehwang Jung) Solution: do not re-calculate topline, when using line() func in diff mode. fixes: vim/vim#15812 closes: vim/vim#15950 https://github.com/vim/vim/commit/05a40e07c2f0e41b708c4c75a6aa7d0e7f6201a3 Co-authored-by: Christian Brabandt --- src/nvim/eval/funcs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index e8b9288717..8f676d7906 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4351,9 +4351,17 @@ static void f_line(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (wp != NULL && tp != NULL) { switchwin_T switchwin; if (switch_win_noblock(&switchwin, wp, tp, true) == OK) { + // in diff mode, prevent that the window scrolls + // and keep the topline + if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff) { + skip_update_topline = true; + } check_cursor(curwin); fp = var2fpos(&argvars[0], true, &fnum, false); } + if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff) { + skip_update_topline = false; + } restore_win_noblock(&switchwin, true); } } else { -- cgit From 5cfa7a72f8c40cdcc0fa93693689915e913806f1 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 20 Feb 2024 17:25:57 +0100 Subject: refactor(message): propagate highlight id instead of attrs Problem: Highlight group id is not propagated to the end of the message call stack, where ext_messages are emitted. Solution: Refactor message functions to pass along highlight group id instead of attr id. --- src/nvim/eval/vars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index d3f836f7f4..35ad00f373 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1407,7 +1407,7 @@ static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t msg_start(); msg_puts(prefix); if (name != NULL) { // "a:" vars don't have a name stored - msg_puts_len(name, name_len, 0); + msg_puts_len(name, name_len, 0, false); } msg_putchar(' '); msg_advance(22); @@ -1429,7 +1429,7 @@ static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t msg_putchar(' '); } - msg_outtrans(string, 0); + msg_outtrans(string, 0, false); if (type == VAR_FUNC || type == VAR_PARTIAL) { msg_puts("()"); -- cgit From ff7518b83cb270f8fcaded19bf640cf4bdfb0ff0 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 11 Nov 2024 13:06:37 +0100 Subject: refactor(highlight): make enum of builtin highlights start with 1 This makes it possible to use HLF_ values directly as highlight id:s and avoids +1 adjustments especially around messages. --- src/nvim/eval/funcs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 8f676d7906..4828d67428 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1342,7 +1342,7 @@ static void f_diff_hlID(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) hlID = HLF_CHD; // Changed line. } } - rettv->vval.v_number = hlID == (hlf_T)0 ? 0 : (hlID + 1); + rettv->vval.v_number = hlID; } /// "empty({expr})" function -- cgit From 0183c3247455a4c2364e5e78d6b716e98ef16aeb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Nov 2024 19:03:29 +0800 Subject: vim-patch:9.1.0870: too many strlen() calls in eval.c (#31267) Problem: too many strlen() calls in eval.c Solution: Refactor eval.c to remove calls to STRLEN() (John Marriott) closes: vim/vim#16066 https://github.com/vim/vim/commit/bd4614f43d0eac4aff743132bab8e53b015ac801 Co-authored-by: John Marriott --- src/nvim/eval/funcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 4828d67428..717280642d 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -7848,8 +7848,8 @@ static void f_substitute(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) || flg == NULL) { rettv->vval.v_string = NULL; } else { - rettv->vval.v_string = do_string_sub((char *)str, (char *)pat, - (char *)sub, expr, (char *)flg); + rettv->vval.v_string = do_string_sub((char *)str, strlen(str), (char *)pat, + (char *)sub, expr, (char *)flg, NULL); } } -- cgit