Mercurial > vim
comparison src/search.c @ 20697:1260b27535b5 v8.2.0902
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Commit: https://github.com/vim/vim/commit/442a85369f3eb9834dbab42add45f7c4106700f4
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 4 20:56:09 2020 +0200
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Problem: Using searchcount() in 'statusline' causes an error.
Solution: Avoid saving/restoring the search patten recursively.
(closes #6194)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 04 Jun 2020 21:00:03 +0200 |
parents | 4c66962d322b |
children | 9064044fd4f6 |
comparison
equal
deleted
inserted
replaced
20696:5e91479ba748 | 20697:1260b27535b5 |
---|---|
354 * canceling incremental searching even if it's called inside user functions. | 354 * canceling incremental searching even if it's called inside user functions. |
355 */ | 355 */ |
356 void | 356 void |
357 save_last_search_pattern(void) | 357 save_last_search_pattern(void) |
358 { | 358 { |
359 if (did_save_last_search_spat != 0) | 359 if (++did_save_last_search_spat != 1) |
360 iemsg("did_save_last_search_spat is not zero"); | 360 // nested call, nothing to do |
361 else | 361 return; |
362 ++did_save_last_search_spat; | |
363 | 362 |
364 saved_last_search_spat = spats[RE_SEARCH]; | 363 saved_last_search_spat = spats[RE_SEARCH]; |
365 if (spats[RE_SEARCH].pat != NULL) | 364 if (spats[RE_SEARCH].pat != NULL) |
366 saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); | 365 saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); |
367 saved_last_idx = last_idx; | 366 saved_last_idx = last_idx; |
369 } | 368 } |
370 | 369 |
371 void | 370 void |
372 restore_last_search_pattern(void) | 371 restore_last_search_pattern(void) |
373 { | 372 { |
374 if (did_save_last_search_spat != 1) | 373 if (--did_save_last_search_spat > 0) |
375 { | 374 // nested call, nothing to do |
376 iemsg("did_save_last_search_spat is not one"); | |
377 return; | 375 return; |
378 } | 376 if (did_save_last_search_spat != 0) |
379 --did_save_last_search_spat; | 377 { |
378 iemsg("restore_last_search_pattern() called more often than save_last_search_pattern()"); | |
379 return; | |
380 } | |
380 | 381 |
381 vim_free(spats[RE_SEARCH].pat); | 382 vim_free(spats[RE_SEARCH].pat); |
382 spats[RE_SEARCH] = saved_last_search_spat; | 383 spats[RE_SEARCH] = saved_last_search_spat; |
383 saved_last_search_spat.pat = NULL; | 384 saved_last_search_spat.pat = NULL; |
384 # if defined(FEAT_EVAL) | 385 # if defined(FEAT_EVAL) |