diff src/optionstr.c @ 34069:170e917524f7 v9.1.0004

patch 9.1.0004: reloading colorscheme when not changing 'background' Commit: https://github.com/vim/vim/commit/83ad2726ff56db70cb2da78e1e4ea0e09941c73b Author: Gregory Anders <greg@gpanders.com> Date: Wed Jan 3 19:48:51 2024 +0100 patch 9.1.0004: reloading colorscheme when not changing 'background' Problem: reloading colorscheme when not changing 'background' Solution: Check, if the background option value actually changed, if not, return early. Only reload colorscheme when bg is changed Currently the highlight groups are re-initialized and the colorscheme (if any) is reloaded anytime 'background' is set, even if it is not changed. This is unnecessary, because if the value was not changed then there is no need to change highlight groups or do anything with the colorscheme. Instead, only reload the colorscheme if the value of 'background' was actually changed. closes: #13700 Signed-off-by: Gregory Anders <greg@gpanders.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 03 Jan 2024 20:00:06 +0100
parents 730a3ddebdd2
children e7d64a3fffe4
line wrap: on
line diff
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -1050,11 +1050,15 @@ expand_set_ambiwidth(optexpand_T *args, 
  * The 'background' option is changed.
  */
     char *
-did_set_background(optset_T *args UNUSED)
+did_set_background(optset_T *args)
 {
     if (check_opt_strings(p_bg, p_bg_values, FALSE) == FAIL)
 	return e_invalid_argument;
 
+    if (args->os_oldval.string != NULL && args->os_oldval.string[0] == *p_bg)
+	// Value was not changed
+	return NULL;
+
 #ifdef FEAT_EVAL
     int dark = (*p_bg == 'd');
 #endif