0
0
mirror of https://github.com/vim/vim.git synced 2025-07-25 10:54:51 -04:00

patch 8.1.0556: saving/restoring search patterns share saved last_idx

Problem:    Saving/restoring search patterns share saved last_idx.
Solution:   Use a separate saved last_idx for saving search patterns for
            functions and incremental search.
This commit is contained in:
Bram Moolenaar 2018-12-01 21:08:21 +01:00
parent 2fb8f684d8
commit ed8bc78d23
2 changed files with 16 additions and 11 deletions

View File

@ -93,12 +93,8 @@ static int lastc_bytelen = 1; /* >1 for multi-byte char */
/* copy of spats[], for keeping the search patterns while executing autocmds */ /* copy of spats[], for keeping the search patterns while executing autocmds */
static struct spat saved_spats[2]; static struct spat saved_spats[2];
# ifdef FEAT_SEARCH_EXTRA # ifdef FEAT_SEARCH_EXTRA
/* copy of spats[RE_SEARCH], for keeping the search patterns while incremental static int saved_spats_last_idx = 0;
* searching */ static int saved_spats_no_hlsearch = 0;
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 # endif
static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */ static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */
@ -310,8 +306,8 @@ save_search_patterns(void)
if (spats[1].pat != NULL) if (spats[1].pat != NULL)
saved_spats[1].pat = vim_strsave(spats[1].pat); saved_spats[1].pat = vim_strsave(spats[1].pat);
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
saved_last_idx = last_idx; saved_spats_last_idx = last_idx;
saved_no_hlsearch = no_hlsearch; saved_spats_no_hlsearch = no_hlsearch;
#endif #endif
} }
} }
@ -329,8 +325,8 @@ restore_search_patterns(void)
vim_free(spats[1].pat); vim_free(spats[1].pat);
spats[1] = saved_spats[1]; spats[1] = saved_spats[1];
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
last_idx = saved_last_idx; last_idx = saved_spats_last_idx;
set_no_hlsearch(saved_no_hlsearch); set_no_hlsearch(saved_spats_no_hlsearch);
#endif #endif
} }
} }
@ -354,6 +350,13 @@ free_search_patterns(void)
#endif #endif
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
// 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;
/* /*
* Save and restore the search pattern for incremental highlight search * Save and restore the search pattern for incremental highlight search
* feature. * feature.
@ -575,7 +578,7 @@ set_last_search_pat(
saved_spats[idx].pat = NULL; saved_spats[idx].pat = NULL;
else else
saved_spats[idx].pat = vim_strsave(spats[idx].pat); saved_spats[idx].pat = vim_strsave(spats[idx].pat);
saved_last_idx = last_idx; saved_spats_last_idx = last_idx;
} }
# ifdef FEAT_SEARCH_EXTRA # ifdef FEAT_SEARCH_EXTRA
/* If 'hlsearch' set and search pat changed: need redraw. */ /* If 'hlsearch' set and search pat changed: need redraw. */

View File

@ -792,6 +792,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
556,
/**/ /**/
555, 555,
/**/ /**/