Mercurial > vim
diff src/structs.h @ 30570:86683eee58ac v9.0.0620
patch 9.0.0620: matchaddpos() can only add up to 8 matches
Commit: https://github.com/vim/vim/commit/50faf02f43d7f1a56ec2023028fca7c72dbce83e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 29 12:50:17 2022 +0100
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 https://github.com/vim/vim/issues/11248)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 29 Sep 2022 14:00:09 +0200 |
parents | 221cca379bd5 |
children | 72e6073a2822 |
line wrap: on
line diff
--- a/src/structs.h +++ b/src/structs.h @@ -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 };