diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-11-30 21:57:55 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-11-30 21:57:55 +0100 |
commit | 01a060da74b756b161e595b39a7877cb7612120a (patch) | |
tree | 0a608cde574b00583e15130261ead0b91c8a02f6 /src/search.c | |
parent | 8ff5af9544a2abc3d344bba017ef96682e098d9d (diff) |
patch 8.1.0552: saved last search pattern may not be restoredv8.1.0552
Problem: Saved last search pattern may not be restored.
Solution: Call restore_last_search_pattern(). Add a check for balancing
saving and restoring the last search pattern.
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c index 98665f795f..d7aa59278d 100644 --- a/src/search.c +++ b/src/search.c @@ -96,6 +96,7 @@ static struct spat saved_spats[2]; /* copy of spats[RE_SEARCH], for keeping the search patterns while incremental * searching */ static struct spat saved_last_search_spat; +static int did_save_last_search_spat = 0; static int saved_last_idx = 0; static int saved_no_hlsearch = 0; # endif @@ -364,6 +365,11 @@ free_search_patterns(void) void save_last_search_pattern(void) { + if (did_save_last_search_spat != 0) + IEMSG("did_save_last_search_spat is not zero"); + else + ++did_save_last_search_spat; + saved_last_search_spat = spats[RE_SEARCH]; if (spats[RE_SEARCH].pat != NULL) saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); @@ -374,8 +380,16 @@ save_last_search_pattern(void) void restore_last_search_pattern(void) { + if (did_save_last_search_spat != 1) + { + IEMSG("did_save_last_search_spat is not one"); + return; + } + --did_save_last_search_spat; + vim_free(spats[RE_SEARCH].pat); spats[RE_SEARCH] = saved_last_search_spat; + saved_last_search_spat.pat = NULL; # if defined(FEAT_EVAL) set_vv_searchforward(); # endif |