patch 9.0.0620: matchaddpos() can only add up to 8 matches
Problem: matchaddpos() can only add up to 8 matches.
Solution: Allocate the array of positions. (closes #11248)
diff --git a/src/structs.h b/src/structs.h
index 31889f6..27fb5bd 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3424,9 +3424,6 @@
// CurSearch
} match_T;
-// number of positions supported by matchaddpos()
-#define MAXPOSMATCH 8
-
/*
* Same as lpos_T, but with additional field len.
*/
@@ -3438,35 +3435,31 @@
} llpos_T;
/*
- * posmatch_T provides an array for storing match items for matchaddpos()
- * function.
- */
-typedef struct posmatch posmatch_T;
-struct posmatch
-{
- llpos_T pos[MAXPOSMATCH]; // array of positions
- int cur; // internal position counter
- linenr_T toplnum; // top buffer line
- linenr_T botlnum; // bottom buffer line
-};
-
-/*
- * matchitem_T provides a linked list for storing match items for ":match" and
- * the match functions.
+ * matchitem_T provides a linked list for storing match items for ":match",
+ * matchadd() and matchaddpos().
*/
typedef struct matchitem matchitem_T;
struct matchitem
{
- matchitem_T *next;
- int id; // match ID
- int priority; // match priority
- char_u *pattern; // pattern to highlight
- regmmatch_T match; // regexp program for pattern
- posmatch_T pos; // position matches
- match_T hl; // struct for doing the actual highlighting
- int hlg_id; // highlight group ID
+ matchitem_T *mit_next;
+ int mit_id; // match ID
+ int mit_priority; // match priority
+
+ // Either a pattern is defined (mit_pattern is not NUL) or a list of
+ // positions is given (mit_pos is not NULL and mit_pos_count > 0).
+ char_u *mit_pattern; // pattern to highlight
+ regmmatch_T mit_match; // regexp program for pattern
+
+ llpos_T *mit_pos_array; // array of positions
+ int mit_pos_count; // nr of entries in mit_pos
+ int mit_pos_cur; // internal position counter
+ linenr_T mit_toplnum; // top buffer line
+ linenr_T mit_botlnum; // bottom buffer line
+
+ match_T mit_hl; // struct for doing the actual highlighting
+ int mit_hlg_id; // highlight group ID
#ifdef FEAT_CONCEAL
- int conceal_char; // cchar for Conceal highlighting
+ int mit_conceal_char; // cchar for Conceal highlighting
#endif
};