]> granicus.if.org Git - vim/commitdiff
patch 8.1.0638: text property highlighting is off by one column v8.1.0638
authorBram Moolenaar <Bram@vim.org>
Tue, 25 Dec 2018 23:25:20 +0000 (00:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 Dec 2018 23:25:20 +0000 (00:25 +0100)
Problem:    Text property highlighting is off by one column. (Bjorn Linse)
Solution:   Update text property highlighting earlier.  Let it overrule syntax
            highlighting.

src/screen.c
src/structs.h
src/version.c

index ed1d4a3914b55ceba8c09b640c214935793a5bce..62f0d136d77bc77f187ee14b8b866e546ce0bfc3 100644 (file)
@@ -4294,6 +4294,66 @@ win_line(
            }
 #endif
 
+#ifdef FEAT_TEXT_PROP
+           if (text_props != NULL)
+           {
+               int pi;
+
+               // Check if any active property ends.
+               for (pi = 0; pi < text_props_active; ++pi)
+               {
+                   int tpi = text_prop_idxs[pi];
+
+                   if (col >= text_props[tpi].tp_col - 1
+                                                 + text_props[tpi].tp_len)
+                   {
+                       if (pi + 1 < text_props_active)
+                           mch_memmove(text_prop_idxs + pi,
+                                       text_prop_idxs + pi + 1,
+                                       sizeof(int)
+                                        * (text_props_active - (pi + 1)));
+                       --text_props_active;
+                       --pi;
+                   }
+               }
+
+               // Add any text property that starts in this column.
+               while (text_prop_next < text_prop_count
+                          && col >= text_props[text_prop_next].tp_col - 1)
+                   text_prop_idxs[text_props_active++] = text_prop_next++;
+
+               text_prop_type = NULL;
+               if (text_props_active > 0)
+               {
+                   int max_priority = INT_MIN;
+                   int max_col = 0;
+
+                   // Get the property type with the highest priority
+                   // and/or starting last.
+                   for (pi = 0; pi < text_props_active; ++pi)
+                   {
+                       int             tpi = text_prop_idxs[pi];
+                       proptype_T  *pt;
+
+                       pt = text_prop_type_by_id(
+                               curwin->w_buffer, text_props[tpi].tp_type);
+                       if (pt != NULL
+                               && (pt->pt_priority > max_priority
+                                   || (pt->pt_priority == max_priority
+                                   && text_props[tpi].tp_col >= max_col)))
+                       {
+                           text_prop_type = pt;
+                           max_priority = pt->pt_priority;
+                           max_col = text_props[tpi].tp_col;
+                       }
+                   }
+                   if (text_prop_type != NULL)
+                       text_prop_attr =
+                                    syn_id2attr(text_prop_type->pt_hl_id);
+               }
+           }
+#endif
+
            /* Decide which of the highlight attributes to use. */
            attr_pri = TRUE;
 #ifdef LINE_ATTR
@@ -4653,8 +4713,8 @@ win_line(
 #endif
 
 #ifdef FEAT_SYN_HL
-               /* Get syntax attribute, unless still at the start of the line
-                * (double-wide char that doesn't fit). */
+               // Get syntax attribute, unless still at the start of the line
+               // (double-wide char that doesn't fit).
                v = (long)(ptr - line);
                if (has_syntax && v > 0)
                {
@@ -4686,10 +4746,16 @@ win_line(
                    line = ml_get_buf(wp->w_buffer, lnum, FALSE);
                    ptr = line + v;
 
-                   if (!attr_pri)
-                       char_attr = syntax_attr;
-                   else
-                       char_attr = hl_combine_attr(syntax_attr, char_attr);
+# ifdef FEAT_TEXT_PROP
+                   // Text properties overrule syntax highlighting.
+                   if (text_prop_attr == 0)
+#endif
+                   {
+                       if (!attr_pri)
+                           char_attr = syntax_attr;
+                       else
+                           char_attr = hl_combine_attr(syntax_attr, char_attr);
+                   }
 # ifdef FEAT_CONCEAL
                    /* no concealing past the end of the line, it interferes
                     * with line highlighting */
@@ -4701,66 +4767,6 @@ win_line(
                }
 #endif
 
-#ifdef FEAT_TEXT_PROP
-               if (text_props != NULL)
-               {
-                   int pi;
-
-                   // Check if any active property ends.
-                   for (pi = 0; pi < text_props_active; ++pi)
-                   {
-                       int tpi = text_prop_idxs[pi];
-
-                       if (col >= text_props[tpi].tp_col - 1
-                                                     + text_props[tpi].tp_len)
-                       {
-                           if (pi + 1 < text_props_active)
-                               mch_memmove(text_prop_idxs + pi,
-                                           text_prop_idxs + pi + 1,
-                                           sizeof(int)
-                                            * (text_props_active - (pi + 1)));
-                           --text_props_active;
-                           --pi;
-                       }
-                   }
-
-                   // Add any text property that starts in this column.
-                   while (text_prop_next < text_prop_count
-                              && col >= text_props[text_prop_next].tp_col - 1)
-                       text_prop_idxs[text_props_active++] = text_prop_next++;
-
-                   text_prop_type = NULL;
-                   if (text_props_active > 0)
-                   {
-                       int max_priority = INT_MIN;
-                       int max_col = 0;
-
-                       // Get the property type with the highest priority
-                       // and/or starting last.
-                       for (pi = 0; pi < text_props_active; ++pi)
-                       {
-                           int         tpi = text_prop_idxs[pi];
-                           proptype_T  *pt;
-
-                           pt = text_prop_type_by_id(
-                                   curwin->w_buffer, text_props[tpi].tp_type);
-                           if (pt != NULL
-                                   && (pt->pt_priority > max_priority
-                                       || (pt->pt_priority == max_priority
-                                       && text_props[tpi].tp_col >= max_col)))
-                           {
-                               text_prop_type = pt;
-                               max_priority = pt->pt_priority;
-                               max_col = text_props[tpi].tp_col;
-                           }
-                       }
-                       if (text_prop_type != NULL)
-                           text_prop_attr =
-                                        syn_id2attr(text_prop_type->pt_hl_id);
-                   }
-               }
-#endif
-
 #ifdef FEAT_SPELL
                /* Check spelling (unless at the end of the line).
                 * Only do this when there is no syntax highlighting, the
index 2f2795a1281437e572a7a203c66220311e4583fd..aa59bff2450b825b75b1547729563b279cbddd44 100644 (file)
@@ -705,7 +705,7 @@ typedef struct memline
  */
 typedef struct textprop_S
 {
-    colnr_T    tp_col;         // start column
+    colnr_T    tp_col;         // start column (one based)
     colnr_T    tp_len;         // length in bytes
     int                tp_id;          // identifier
     int                tp_type;        // property type
index c51a46d5858e830df0fbb8a25e704361cdd45043..5cffe09c870015d199a31f10a09daa93e3471d64 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    638,
 /**/
     637,
 /**/