mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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.
This commit is contained in:
parent
8ff5af9544
commit
01a060da74
@ -462,6 +462,7 @@ may_do_incsearch_highlighting(
|
||||
int use_last_pat;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
// NOTE: must call restore_last_search_pattern() before returning!
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
@ -633,6 +634,7 @@ may_adjust_incsearch_highlighting(
|
||||
int save;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
// NOTE: must call restore_last_search_pattern() before returning!
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
@ -735,6 +737,7 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
|
||||
int skiplen, patlen;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
// NOTE: must call restore_last_search_pattern() before returning!
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
@ -742,6 +745,7 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
|
||||
restore_last_search_pattern();
|
||||
return FAIL;
|
||||
}
|
||||
restore_last_search_pattern();
|
||||
|
||||
// Add a character from under the cursor for 'incsearch'.
|
||||
if (is_state->did_incsearch)
|
||||
|
14
src/search.c
14
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
|
||||
|
@ -792,6 +792,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
552,
|
||||
/**/
|
||||
551,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user