diff options
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index d7984d675d..517db05a40 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -320,10 +320,9 @@ static bool saved_no_hlsearch = false; /// cancelling incremental searching even if it's called inside user functions. 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++; + if (++did_save_last_search_spat != 1) { + // nested call, nothing to do + return; } saved_last_search_spat = spats[RE_SEARCH]; @@ -336,11 +335,15 @@ void 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"); + if (--did_save_last_search_spat > 0) { + // nested call, nothing to do + return; + } + if (did_save_last_search_spat != 0) { + iemsg("restore_last_search_pattern() called more often than" + " save_last_search_pattern()"); return; } - did_save_last_search_spat--; xfree(spats[RE_SEARCH].pat); spats[RE_SEARCH] = saved_last_search_spat; |