mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 23:06:14 +00:00
vim-patch:8.1.0552: saved last search pattern may not be restored
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.
01a060da74
This commit is contained in:
@@ -99,6 +99,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 bool saved_no_hlsearch = false;
|
||||
|
||||
@@ -316,6 +317,12 @@ void free_search_patterns(void)
|
||||
/// 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++;
|
||||
}
|
||||
|
||||
saved_last_search_spat = spats[RE_SEARCH];
|
||||
if (spats[RE_SEARCH].pat != NULL) {
|
||||
saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat);
|
||||
@@ -326,8 +333,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");
|
||||
return;
|
||||
}
|
||||
did_save_last_search_spat--;
|
||||
|
||||
xfree(spats[RE_SEARCH].pat);
|
||||
spats[RE_SEARCH] = saved_last_search_spat;
|
||||
saved_last_search_spat.pat = NULL;
|
||||
set_vv_searchforward();
|
||||
last_idx = saved_last_idx;
|
||||
set_no_hlsearch(saved_no_hlsearch);
|
||||
|
Reference in New Issue
Block a user