Mercurial > vim
comparison src/evalfunc.c @ 29189:d1e263ecf634 v8.2.5114
patch 8.2.5114: time limit on searchpair() does not work properly
Commit: https://github.com/vim/vim/commit/5ea38d1e7fd597ffde13b292d43e12747f20e97f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 16 21:20:48 2022 +0100
patch 8.2.5114: time limit on searchpair() does not work properly
Problem: Time limit on searchpair() does not work properly.
Solution: Set the time limit once instead of for each regexp. (closes https://github.com/vim/vim/issues/10562)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 Jun 2022 22:30:03 +0200 |
parents | 755ab148288b |
children | f27ec19f2034 |
comparison
equal
deleted
inserted
replaced
29188:f96e0bc4494b | 29189:d1e263ecf634 |
---|---|
8973 options |= SEARCH_START; | 8973 options |= SEARCH_START; |
8974 | 8974 |
8975 if (skip != NULL) | 8975 if (skip != NULL) |
8976 use_skip = eval_expr_valid_arg(skip); | 8976 use_skip = eval_expr_valid_arg(skip); |
8977 | 8977 |
8978 #ifdef FEAT_RELTIME | |
8979 if (time_limit > 0) | |
8980 init_regexp_timeout(time_limit); | |
8981 #endif | |
8978 save_cursor = curwin->w_cursor; | 8982 save_cursor = curwin->w_cursor; |
8979 pos = curwin->w_cursor; | 8983 pos = curwin->w_cursor; |
8980 CLEAR_POS(&firstpos); | 8984 CLEAR_POS(&firstpos); |
8981 CLEAR_POS(&foundpos); | 8985 CLEAR_POS(&foundpos); |
8982 pat = pat3; | 8986 pat = pat3; |
8984 { | 8988 { |
8985 searchit_arg_T sia; | 8989 searchit_arg_T sia; |
8986 | 8990 |
8987 CLEAR_FIELD(sia); | 8991 CLEAR_FIELD(sia); |
8988 sia.sa_stop_lnum = lnum_stop; | 8992 sia.sa_stop_lnum = lnum_stop; |
8989 #ifdef FEAT_RELTIME | |
8990 sia.sa_tm = time_limit; | |
8991 #endif | |
8992 n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, | 8993 n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, |
8993 options, RE_SEARCH, &sia); | 8994 options, RE_SEARCH, &sia); |
8994 if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))) | 8995 if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))) |
8995 // didn't find it or found the first match again: FAIL | 8996 // didn't find it or found the first match again: FAIL |
8996 break; | 8997 break; |
9072 // If 'n' flag is used or search failed: restore cursor position. | 9073 // If 'n' flag is used or search failed: restore cursor position. |
9073 if ((flags & SP_NOMOVE) || retval == 0) | 9074 if ((flags & SP_NOMOVE) || retval == 0) |
9074 curwin->w_cursor = save_cursor; | 9075 curwin->w_cursor = save_cursor; |
9075 | 9076 |
9076 theend: | 9077 theend: |
9078 #ifdef FEAT_RELTIME | |
9079 disable_regexp_timeout(); | |
9080 #endif | |
9077 vim_free(pat2); | 9081 vim_free(pat2); |
9078 vim_free(pat3); | 9082 vim_free(pat3); |
9079 if (p_cpo == empty_option) | 9083 if (p_cpo == empty_option) |
9080 p_cpo = save_cpo; | 9084 p_cpo = save_cpo; |
9081 else | 9085 else |