aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_nfa.c
diff options
context:
space:
mode:
authorDavid Bürgin <676c7473@gmail.com>2015-05-14 14:23:50 +0200
committerJustin M. Keyes <justinkz@gmail.com>2015-05-26 01:07:37 -0400
commit5a9ad68b258f33ebd7fa0a5da47b308f50f1e5e7 (patch)
treea69628cbe4e02d21f76cb22297b3952a9b9a1ff3 /src/nvim/regexp_nfa.c
parentc6da5033362c76f3641f4871046a40465fe0615a (diff)
downloadrneovim-5a9ad68b258f33ebd7fa0a5da47b308f50f1e5e7.tar.gz
rneovim-5a9ad68b258f33ebd7fa0a5da47b308f50f1e5e7.tar.bz2
rneovim-5a9ad68b258f33ebd7fa0a5da47b308f50f1e5e7.zip
vim-patch:7.4.582 #2653
Problem: Can't match "%>80v" properly. (Axel Bender) Solution: Correctly handle ">". (Christian Brabandt) https://github.com/vim/vim/commit/v7-4-582 See https://groups.google.com/d/msg/vim_dev/n-02i4FnOcw/P3Yyx1OLeXgJ Slightly adapted due to the long_u refactoring in 2ceb1c74d591a07183ee02baf6ff1e205c87c6b8. Reviewed-by: Florian Walch <florian@fwalch.com> Fixes #2726
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r--src/nvim/regexp_nfa.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 9cf35c53bb..4ef91814ac 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5742,17 +5742,27 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
// Bail out quickly when there can't be a match, avoid the overhead of
// win_linetabsize() on long lines.
- if ((col > t->state->val && op != 1)
- || (col - 1 > t->state->val && op == 1)) {
+ if (op != 1 && col > t->state->val) {
break;
}
- uintmax_t lts = win_linetabsize(reg_win == NULL ? curwin : reg_win,
- regline,
- col);
- assert(t->state->val >= 0);
- result = nfa_re_num_cmp((uintmax_t)t->state->val,
- op,
- lts + 1);
+
+ result = FALSE;
+ win_T *wp = reg_win == NULL ? curwin : reg_win;
+ if (op == 1 && col - 1 > t->state->val && col > 100) {
+ long ts = wp->w_buffer->b_p_ts;
+
+ // Guess that a character won't use more columns than 'tabstop',
+ // with a minimum of 4.
+ if (ts < 4) {
+ ts = 4;
+ }
+ result = col > t->state->val * ts;
+ }
+ if (!result) {
+ uintmax_t lts = win_linetabsize(wp, regline, col);
+ assert(t->state->val >= 0);
+ result = nfa_re_num_cmp((uintmax_t)t->state->val, op, lts + 1);
+ }
if (result) {
add_here = true;
add_state = t->state->out;