0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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)
This commit is contained in:
Bram Moolenaar
2022-09-29 12:50:17 +01:00
parent 572a4433c8
commit 50faf02f43
7 changed files with 184 additions and 145 deletions

View File

@@ -3424,9 +3424,6 @@ typedef struct
// 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 @@ typedef struct
} 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
};