diff src/optionstr.c @ 23952:44be09b25619 v8.2.2518

patch 8.2.2518: 'listchars' should be window-local Commit: https://github.com/vim/vim/commit/eed9d46293f0842aad0d50ff3a526f9a48b12421 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 15 20:38:25 2021 +0100 patch 8.2.2518: 'listchars' should be window-local Problem: 'listchars' should be window-local. Solution: Make 'listchars' global-local. (Yegappan Lakshmanan, Marco Hinz, closes #5206, closes #7850)
author Bram Moolenaar <Bram@vim.org>
date Mon, 15 Feb 2021 20:45:04 +0100
parents 8152b7daebad
children a9ff8368d35f
line wrap: on
line diff
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -862,10 +862,24 @@ did_set_string_option(
     {
 	if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
 	    errmsg = e_invarg;
-	else if (set_chars_option(&p_lcs) != NULL)
-	    errmsg = _("E834: Conflicts with value of 'listchars'");
-	else if (set_chars_option(&p_fcs) != NULL)
+	else if (set_chars_option(curwin, &p_fcs) != NULL)
 	    errmsg = _("E835: Conflicts with value of 'fillchars'");
+	else
+	{
+	    tabpage_T	*tp;
+	    win_T	*wp;
+
+	    FOR_ALL_TAB_WINDOWS(tp, wp)
+	    {
+		if (set_chars_option(wp, &wp->w_p_lcs) != NULL)
+		{
+		    errmsg = _("E834: Conflicts with value of 'listchars'");
+		    goto ambw_end;
+		}
+	    }
+	}
+ambw_end:
+	{}
     }
 
     // 'background'
@@ -1292,16 +1306,37 @@ did_set_string_option(
 	}
     }
 
-    // 'listchars'
+    // global 'listchars'
     else if (varp == &p_lcs)
     {
-	errmsg = set_chars_option(varp);
+	errmsg = set_chars_option(curwin, varp);
+	if (errmsg == NULL)
+	{
+	    tabpage_T	*tp;
+	    win_T		*wp;
+
+	    // The current window is set to use the global 'listchars' value.
+	    // So clear the window-local value.
+	    if (!(opt_flags & OPT_GLOBAL))
+		clear_string_option(&curwin->w_p_lcs);
+	    FOR_ALL_TAB_WINDOWS(tp, wp)
+	    {
+		errmsg = set_chars_option(wp, &wp->w_p_lcs);
+		if (errmsg)
+		    break;
+	    }
+	    redraw_all_later(NOT_VALID);
+	}
     }
 
+    // local 'listchars'
+    else if (varp == &curwin->w_p_lcs)
+	errmsg = set_chars_option(curwin, varp);
+
     // 'fillchars'
     else if (varp == &p_fcs)
     {
-	errmsg = set_chars_option(varp);
+	errmsg = set_chars_option(curwin, varp);
     }
 
 #ifdef FEAT_CMDWIN