patch 9.1.0004: reloading colorscheme when not changing 'background'

Commit: 
https://github.com/vim/vim/commit/83ad2726ff56db70cb2da78e1e4ea0e09941c73b
Author: Gregory Anders <[email protected]>
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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index e6c20220b..4dff6b53f 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2023 Dec 20
+*options.txt*  For Vim version 9.1.  Last change: 2024 Jan 03
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -997,11 +997,11 @@ A jump table for the options with a short description can 
be found at |Q_op|.
        what the background color looks like.  For changing the background
        color, see |:hi-normal|.
 
-       When 'background' is set Vim will adjust the default color groups for
-       the new value.  But the colors used for syntax highlighting will not
-       change.                                 *g:colors_name*
+       When 'background' is changed Vim will adjust the default color groups
+       for the new value.  But the colors used for syntax highlighting will
+       not change.                                     *g:colors_name*
        When a color scheme is loaded (the "g:colors_name" variable is set)
-       setting 'background' will cause the color scheme to be reloaded.  If
+       changing 'background' will cause the color scheme to be reloaded.  If
        the color scheme adjusts to the value of 'background' this will work.
        However, if the color scheme sets 'background' itself the effect may
        be undone.  First delete the "g:colors_name" variable when needed.
diff --git a/src/optionstr.c b/src/optionstr.c
index 326e62552..65a80afe1 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -1050,11 +1050,15 @@ expand_set_ambiwidth(optexpand_T *args, int 
*numMatches, char_u ***matches)
  * 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
diff --git a/src/version.c b/src/version.c
index 749d6af13..e83654fd5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4,
 /**/
     3,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rL6TG-00BBLq-Dm%40256bit.org.

Raspunde prin e-mail lui