aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_bt.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-19 16:42:24 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-30 08:35:13 +0800
commit1bbe8ec2820497b8a61adcd138da350445b0ad92 (patch)
treeb29ab8b57ff838acfeed0b4cbbad39dedde1d51c /src/nvim/regexp_bt.c
parente5428d10b5a49e9395190482ff35bbac0c1117ea (diff)
downloadrneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.tar.gz
rneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.tar.bz2
rneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.zip
vim-patch:8.2.3110: a pattern that matches the cursor position is complicated
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 vim/vim#8497, closes vim/vim#8179) https://github.com/vim/vim/commit/04db26b36000a4677b95403ec94bd11f6cc73975 Also use `n = ++vcol` in regexp_bt.c as `++vcol` alone fails lint.
Diffstat (limited to 'src/nvim/regexp_bt.c')
-rw-r--r--src/nvim/regexp_bt.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index 3835a2bbae..7d0b9a7a77 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -1578,14 +1578,19 @@ static char_u *regatom(int *flagp)
}
default:
- if (ascii_isdigit(c) || c == '<' || c == '>'
- || c == '\'') {
+ if (ascii_isdigit(c) || c == '<' || c == '>' || c == '\'' || c == '.') {
uint32_t n = 0;
int cmp;
+ bool cur = false;
cmp = c;
- if (cmp == '<' || cmp == '>')
+ if (cmp == '<' || cmp == '>') {
c = getchr();
+ }
+ if (no_Magic(c) == '.') {
+ cur = true;
+ c = getchr();
+ }
while (ascii_isdigit(c)) {
n = n * 10 + (uint32_t)(c - '0');
c = getchr();
@@ -1602,14 +1607,31 @@ static char_u *regatom(int *flagp)
}
break;
} 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);
+ n = ++vcol;
+ }
ret = regnode(RE_VCOL);
}
if (ret == JUST_CALC_SIZE) {