Mercurial > vim
comparison src/regexp_bt.c @ 25147:10b269321459 v8.2.3110
patch 8.2.3110: a pattern that matches the cursor position is complicated
Commit: https://github.com/vim/vim/commit/04db26b36000a4677b95403ec94bd11f6cc73975
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jul 5 20:15:23 2021 +0200
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 #8497, closes #8179)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Jul 2021 20:30:03 +0200 |
parents | 97789fcef0cf |
children | 078edc1821bf |
comparison
equal
deleted
inserted
replaced
25146:84fff3a2c3d3 | 25147:10b269321459 |
---|---|
1626 break; | 1626 break; |
1627 } | 1627 } |
1628 | 1628 |
1629 default: | 1629 default: |
1630 if (VIM_ISDIGIT(c) || c == '<' || c == '>' | 1630 if (VIM_ISDIGIT(c) || c == '<' || c == '>' |
1631 || c == '\'') | 1631 || c == '\'' || c == '.') |
1632 { | 1632 { |
1633 long_u n = 0; | 1633 long_u n = 0; |
1634 int cmp; | 1634 int cmp; |
1635 int cur = FALSE; | |
1635 | 1636 |
1636 cmp = c; | 1637 cmp = c; |
1637 if (cmp == '<' || cmp == '>') | 1638 if (cmp == '<' || cmp == '>') |
1638 c = getchr(); | 1639 c = getchr(); |
1640 if (no_Magic(c) == '.') | |
1641 { | |
1642 cur = TRUE; | |
1643 c = getchr(); | |
1644 } | |
1639 while (VIM_ISDIGIT(c)) | 1645 while (VIM_ISDIGIT(c)) |
1640 { | 1646 { |
1641 n = n * 10 + (c - '0'); | 1647 n = n * 10 + (c - '0'); |
1642 c = getchr(); | 1648 c = getchr(); |
1643 } | 1649 } |
1655 } | 1661 } |
1656 break; | 1662 break; |
1657 } | 1663 } |
1658 else if (c == 'l' || c == 'c' || c == 'v') | 1664 else if (c == 'l' || c == 'c' || c == 'v') |
1659 { | 1665 { |
1666 if (cur && n) | |
1667 { | |
1668 semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c)); | |
1669 rc_did_emsg = TRUE; | |
1670 return NULL; | |
1671 } | |
1660 if (c == 'l') | 1672 if (c == 'l') |
1661 { | 1673 { |
1674 if (cur) | |
1675 n = curwin->w_cursor.lnum; | |
1662 ret = regnode(RE_LNUM); | 1676 ret = regnode(RE_LNUM); |
1663 if (save_prev_at_start) | 1677 if (save_prev_at_start) |
1664 at_start = TRUE; | 1678 at_start = TRUE; |
1665 } | 1679 } |
1666 else if (c == 'c') | 1680 else if (c == 'c') |
1681 { | |
1682 if (cur) | |
1683 { | |
1684 n = curwin->w_cursor.col; | |
1685 n++; | |
1686 } | |
1667 ret = regnode(RE_COL); | 1687 ret = regnode(RE_COL); |
1688 } | |
1668 else | 1689 else |
1690 { | |
1691 if (cur) | |
1692 { | |
1693 colnr_T vcol = 0; | |
1694 | |
1695 getvvcol(curwin, &curwin->w_cursor, | |
1696 NULL, NULL, &vcol); | |
1697 ++vcol; | |
1698 n = vcol; | |
1699 } | |
1669 ret = regnode(RE_VCOL); | 1700 ret = regnode(RE_VCOL); |
1701 } | |
1670 if (ret == JUST_CALC_SIZE) | 1702 if (ret == JUST_CALC_SIZE) |
1671 regsize += 5; | 1703 regsize += 5; |
1672 else | 1704 else |
1673 { | 1705 { |
1674 // put the number and the optional | 1706 // put the number and the optional |