Mercurial > vim
comparison src/screen.c @ 11521:578df034735d v8.0.0643
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
commit https://github.com/vim/vim/commit/fbd0b0af6800f6ff89857863d6a07ea03f09ff6c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 17 18:44:21 2017 +0200
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Problem: When 'hlsearch' is set and matching with the last search pattern
is very slow, Vim becomes unusable. Cannot quit search by
pressing CTRL-C.
Solution: When the search times out set a flag and don't try again. Check
for timeout and CTRL-C in NFA loop that adds states.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 17 Jun 2017 18:45:04 +0200 |
parents | 80491a71c716 |
children | 998d2cf59caa |
comparison
equal
deleted
inserted
replaced
11520:8b54fc8a4b2e | 11521:578df034735d |
---|---|
7798 /* Remember whether shl->rm is using a copy of the regprog in | 7798 /* Remember whether shl->rm is using a copy of the regprog in |
7799 * cur->match. */ | 7799 * cur->match. */ |
7800 int regprog_is_copy = (shl != &search_hl && cur != NULL | 7800 int regprog_is_copy = (shl != &search_hl && cur != NULL |
7801 && shl == &cur->hl | 7801 && shl == &cur->hl |
7802 && cur->match.regprog == cur->hl.rm.regprog); | 7802 && cur->match.regprog == cur->hl.rm.regprog); |
7803 int timed_out = FALSE; | |
7803 | 7804 |
7804 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, | 7805 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, |
7805 matchcol, | 7806 matchcol, |
7806 #ifdef FEAT_RELTIME | 7807 #ifdef FEAT_RELTIME |
7807 &(shl->tm) | 7808 &(shl->tm), &timed_out |
7808 #else | 7809 #else |
7809 NULL | 7810 NULL, NULL |
7810 #endif | 7811 #endif |
7811 ); | 7812 ); |
7812 /* Copy the regprog, in case it got freed and recompiled. */ | 7813 /* Copy the regprog, in case it got freed and recompiled. */ |
7813 if (regprog_is_copy) | 7814 if (regprog_is_copy) |
7814 cur->match.regprog = cur->hl.rm.regprog; | 7815 cur->match.regprog = cur->hl.rm.regprog; |
7815 | 7816 |
7816 if (called_emsg || got_int) | 7817 if (called_emsg || got_int || timed_out) |
7817 { | 7818 { |
7818 /* Error while handling regexp: stop using this regexp. */ | 7819 /* Error while handling regexp: stop using this regexp. */ |
7819 if (shl == &search_hl) | 7820 if (shl == &search_hl) |
7820 { | 7821 { |
7821 /* don't free regprog in the match list, it's a copy */ | 7822 /* don't free regprog in the match list, it's a copy */ |