Mercurial > vim
comparison src/tag.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 | c45fb081391c |
children | 68d7bc045dbe |
comparison
equal
deleted
inserted
replaced
11520:8b54fc8a4b2e | 11521:578df034735d |
---|---|
3306 #endif | 3306 #endif |
3307 #endif | 3307 #endif |
3308 save_lnum = curwin->w_cursor.lnum; | 3308 save_lnum = curwin->w_cursor.lnum; |
3309 curwin->w_cursor.lnum = 0; /* start search before first line */ | 3309 curwin->w_cursor.lnum = 0; /* start search before first line */ |
3310 if (do_search(NULL, pbuf[0], pbuf + 1, (long)1, | 3310 if (do_search(NULL, pbuf[0], pbuf + 1, (long)1, |
3311 search_options, NULL)) | 3311 search_options, NULL, NULL)) |
3312 retval = OK; | 3312 retval = OK; |
3313 else | 3313 else |
3314 { | 3314 { |
3315 int found = 1; | 3315 int found = 1; |
3316 int cc; | 3316 int cc; |
3318 /* | 3318 /* |
3319 * try again, ignore case now | 3319 * try again, ignore case now |
3320 */ | 3320 */ |
3321 p_ic = TRUE; | 3321 p_ic = TRUE; |
3322 if (!do_search(NULL, pbuf[0], pbuf + 1, (long)1, | 3322 if (!do_search(NULL, pbuf[0], pbuf + 1, (long)1, |
3323 search_options, NULL)) | 3323 search_options, NULL, NULL)) |
3324 { | 3324 { |
3325 /* | 3325 /* |
3326 * Failed to find pattern, take a guess: "^func (" | 3326 * Failed to find pattern, take a guess: "^func (" |
3327 */ | 3327 */ |
3328 found = 2; | 3328 found = 2; |
3329 (void)test_for_static(&tagp); | 3329 (void)test_for_static(&tagp); |
3330 cc = *tagp.tagname_end; | 3330 cc = *tagp.tagname_end; |
3331 *tagp.tagname_end = NUL; | 3331 *tagp.tagname_end = NUL; |
3332 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); | 3332 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); |
3333 if (!do_search(NULL, '/', pbuf, (long)1, | 3333 if (!do_search(NULL, '/', pbuf, (long)1, |
3334 search_options, NULL)) | 3334 search_options, NULL, NULL)) |
3335 { | 3335 { |
3336 /* Guess again: "^char * \<func (" */ | 3336 /* Guess again: "^char * \<func (" */ |
3337 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", | 3337 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", |
3338 tagp.tagname); | 3338 tagp.tagname); |
3339 if (!do_search(NULL, '/', pbuf, (long)1, | 3339 if (!do_search(NULL, '/', pbuf, (long)1, |
3340 search_options, NULL)) | 3340 search_options, NULL, NULL)) |
3341 found = 0; | 3341 found = 0; |
3342 } | 3342 } |
3343 *tagp.tagname_end = cc; | 3343 *tagp.tagname_end = cc; |
3344 } | 3344 } |
3345 if (found == 0) | 3345 if (found == 0) |