summaryrefslogtreecommitdiff
path: root/src/regexp_bt.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-05 20:15:23 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-05 20:15:23 +0200
commit04db26b36000a4677b95403ec94bd11f6cc73975 (patch)
tree409bf4069a07c8276f943b97e8bf93b61c60b01b /src/regexp_bt.c
parentf6d877975ba93fc9b4bee2c5d2aff88dbf9bea59 (diff)
downloadvim-git-04db26b36000a4677b95403ec94bd11f6cc73975.tar.gz
patch 8.2.3110: a pattern that matches the cursor position is complicatedv8.2.3110
Problem: A pattern that matches the cursor position is bit complicated. Solution: Use a dot to indicate the cursor line and column. (Christian Brabandt, closes #8497, closes #8179)
Diffstat (limited to 'src/regexp_bt.c')
-rw-r--r--src/regexp_bt.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/regexp_bt.c b/src/regexp_bt.c
index 70ddfe986..dae6d519b 100644
--- a/src/regexp_bt.c
+++ b/src/regexp_bt.c
@@ -1628,14 +1628,20 @@ regatom(int *flagp)
default:
if (VIM_ISDIGIT(c) || c == '<' || c == '>'
- || c == '\'')
+ || c == '\'' || c == '.')
{
long_u n = 0;
int cmp;
+ int cur = FALSE;
cmp = c;
if (cmp == '<' || cmp == '>')
c = getchr();
+ if (no_Magic(c) == '.')
+ {
+ cur = TRUE;
+ c = getchr();
+ }
while (VIM_ISDIGIT(c))
{
n = n * 10 + (c - '0');
@@ -1657,16 +1663,42 @@ regatom(int *flagp)
}
else if (c == 'l' || c == 'c' || c == 'v')
{
+ if (cur && n)
+ {
+ semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c));
+ rc_did_emsg = TRUE;
+ return NULL;
+ }
if (c == 'l')
{
+ if (cur)
+ n = curwin->w_cursor.lnum;
ret = regnode(RE_LNUM);
if (save_prev_at_start)
at_start = TRUE;
}
else if (c == 'c')
+ {
+ if (cur)
+ {
+ n = curwin->w_cursor.col;
+ n++;
+ }
ret = regnode(RE_COL);
+ }
else
+ {
+ if (cur)
+ {
+ colnr_T vcol = 0;
+
+ getvvcol(curwin, &curwin->w_cursor,
+ NULL, NULL, &vcol);
+ ++vcol;
+ n = vcol;
+ }
ret = regnode(RE_VCOL);
+ }
if (ret == JUST_CALC_SIZE)
regsize += 5;
else