diff src/option.c @ 18068:1101eacc1444 v8.1.2029

patch 8.1.2029: cannot control 'cursorline' highlighting well Commit: https://github.com/vim/vim/commit/017ba07fa2cdc578245618717229444fd50c470d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 14 21:01:23 2019 +0200 patch 8.1.2029: cannot control 'cursorline' highlighting well Problem: Cannot control 'cursorline' highlighting well. Solution: Add "screenline". (Christian Brabandt, closes https://github.com/vim/vim/issues/4933)
author Bram Moolenaar <Bram@vim.org>
date Sat, 14 Sep 2019 21:15:04 +0200
parents 88b5c2b4e3d2
children df5778d73320
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -88,6 +88,9 @@ static int check_opt_wim(void);
 #ifdef FEAT_LINEBREAK
 static int briopt_check(win_T *wp);
 #endif
+#ifdef FEAT_SYN_HL
+static int fill_culopt_flags(char_u *val, win_T *wp);
+#endif
 
 /*
  * Initialize the options, first part.
@@ -2447,7 +2450,9 @@ didset_options(void)
     /* initialize the table for 'breakat'. */
     fill_breakat_flags();
 #endif
-
+#ifdef FEAT_SYN_HL
+    fill_culopt_flags(NULL, curwin);
+#endif
 }
 
 /*
@@ -3136,8 +3141,7 @@ did_set_string_option(
     else if (varp == &curwin->w_p_culopt
 				  || gvarp == &curwin->w_allbuf_opt.wo_culopt)
     {
-	if (**varp == NUL
-		    || check_opt_strings(*varp, p_culopt_values, FALSE) != OK)
+	if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK)
 	    errmsg = e_invarg;
     }
 
@@ -7781,6 +7785,9 @@ win_copy_options(win_T *wp_from, win_T *
 #if defined(FEAT_LINEBREAK)
     briopt_check(wp_to);
 #endif
+#ifdef FEAT_SYN_HL
+    fill_culopt_flags(NULL, wp_to);
+#endif
 }
 
 /*
@@ -9515,3 +9522,55 @@ get_winbuf_options(int bufopt)
     return d;
 }
 #endif
+
+#ifdef FEAT_SYN_HL
+/*
+ * This is called when 'culopt' is changed
+ */
+    static int
+fill_culopt_flags(char_u *val, win_T *wp)
+{
+    char_u	*p;
+    char_u	culopt_flags_new = 0;
+
+    if (val == NULL)
+	p = wp->w_p_culopt;
+    else
+	p = val;
+    while (*p != NUL)
+    {
+	if (STRNCMP(p, "line", 4) == 0)
+	{
+	    p += 4;
+	    culopt_flags_new |= CULOPT_LINE;
+	}
+	else if (STRNCMP(p, "both", 4) == 0)
+	{
+	    p += 4;
+	    culopt_flags_new |= CULOPT_LINE | CULOPT_NBR;
+	}
+	else if (STRNCMP(p, "number", 6) == 0)
+	{
+	    p += 6;
+	    culopt_flags_new |= CULOPT_NBR;
+	}
+	else if (STRNCMP(p, "screenline", 10) == 0)
+	{
+	    p += 10;
+	    culopt_flags_new |= CULOPT_SCRLINE;
+	}
+
+	if (*p != ',' && *p != NUL)
+	    return FAIL;
+	if (*p == ',')
+	    ++p;
+    }
+
+    // Can't have both "line" and "screenline".
+    if ((culopt_flags_new & CULOPT_LINE) && (culopt_flags_new & CULOPT_SCRLINE))
+	return FAIL;
+    wp->w_p_culopt_flags = culopt_flags_new;
+
+    return OK;
+}
+#endif