diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-04 09:09:00 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-12-04 10:07:05 +0800 |
commit | 46e4be0fd0002233bde613295607ce5eeb498567 (patch) | |
tree | 4e12bbbb51cca63f4f745c6061139768a381380b /src/nvim/regexp.c | |
parent | a91ba088abf7b21f640f671ad7f211c0957b4765 (diff) | |
download | rneovim-46e4be0fd0002233bde613295607ce5eeb498567.tar.gz rneovim-46e4be0fd0002233bde613295607ce5eeb498567.tar.bz2 rneovim-46e4be0fd0002233bde613295607ce5eeb498567.zip |
vim-patch:8.2.2295: incsearch does not detect empty pattern properly
Problem: Incsearch does not detect empty pattern properly.
Solution: Return magic state when skipping over a pattern. (Christian
Brabandt, closes vim/vim#7612, closes vim/vim#6420)
https://github.com/vim/vim/commit/d93a7fc1a98a58f8101ee780d4735079ad99ae35
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index e58a8fa06a..7335345161 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -316,11 +316,7 @@ static int re_has_z; ///< \z item detected static unsigned regflags; ///< RF_ flags for prog static int had_eol; ///< true when EOL found by vim_regcomp() -static int reg_magic; // magicness of the pattern: -#define MAGIC_NONE 1 // "\V" very unmagic -#define MAGIC_OFF 2 // "\M" or 'magic' off -#define MAGIC_ON 3 // "\m" or 'magic' -#define MAGIC_ALL 4 // "\v" very magic +static magic_T reg_magic; ///< magicness of the pattern static int reg_string; // matching with a string instead of a buffer // line @@ -485,7 +481,7 @@ static char_u *skip_anyof(char *p) /// Skip strings inside [ and ]. char *skip_regexp(char *startp, int delim, int magic) { - return skip_regexp_ex(startp, delim, magic, NULL, NULL); + return skip_regexp_ex(startp, delim, magic, NULL, NULL, NULL); } /// Call skip_regexp() and when the delimiter does not match give an error and @@ -506,9 +502,11 @@ char *skip_regexp_err(char *startp, int delim, int magic) /// expression and change "\?" to "?". If "*newp" is not NULL the expression /// is changed in-place. /// If a "\?" is changed to "?" then "dropped" is incremented, unless NULL. -char *skip_regexp_ex(char *startp, int dirc, int magic, char **newp, int *dropped) +/// If "magic_val" is not NULL, returns the effective magicness of the pattern +char *skip_regexp_ex(char *startp, int dirc, int magic, char **newp, int *dropped, + magic_T *magic_val) { - int mymagic; + magic_T mymagic; char *p = startp; if (magic) { @@ -549,6 +547,9 @@ char *skip_regexp_ex(char *startp, int dirc, int magic, char **newp, int *droppe } } } + if (magic_val != NULL) { + *magic_val = mymagic; + } return p; } |