Skip to content

Commit ed8bc78

Browse files
committed
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.
1 parent 2fb8f68 commit ed8bc78

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/search.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,8 @@ static int lastc_bytelen = 1; /* >1 for multi-byte char */
9393
/* copy of spats[], for keeping the search patterns while executing autocmds */
9494
static struct spat saved_spats[2];
9595
# ifdef FEAT_SEARCH_EXTRA
96-
/* copy of spats[RE_SEARCH], for keeping the search patterns while incremental
97-
* searching */
98-
static struct spat saved_last_search_spat;
99-
static int did_save_last_search_spat = 0;
100-
static int saved_last_idx = 0;
101-
static int saved_no_hlsearch = 0;
96+
static int saved_spats_last_idx = 0;
97+
static int saved_spats_no_hlsearch = 0;
10298
# endif
10399

104100
static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */
@@ -310,8 +306,8 @@ save_search_patterns(void)
310306
if (spats[1].pat != NULL)
311307
saved_spats[1].pat = vim_strsave(spats[1].pat);
312308
#ifdef FEAT_SEARCH_EXTRA
313-
saved_last_idx = last_idx;
314-
saved_no_hlsearch = no_hlsearch;
309+
saved_spats_last_idx = last_idx;
310+
saved_spats_no_hlsearch = no_hlsearch;
315311
#endif
316312
}
317313
}
@@ -329,8 +325,8 @@ restore_search_patterns(void)
329325
vim_free(spats[1].pat);
330326
spats[1] = saved_spats[1];
331327
#ifdef FEAT_SEARCH_EXTRA
332-
last_idx = saved_last_idx;
333-
set_no_hlsearch(saved_no_hlsearch);
328+
last_idx = saved_spats_last_idx;
329+
set_no_hlsearch(saved_spats_no_hlsearch);
334330
#endif
335331
}
336332
}
@@ -354,6 +350,13 @@ free_search_patterns(void)
354350
#endif
355351

356352
#ifdef FEAT_SEARCH_EXTRA
353+
// copy of spats[RE_SEARCH], for keeping the search patterns while incremental
354+
// searching
355+
static struct spat saved_last_search_spat;
356+
static int did_save_last_search_spat = 0;
357+
static int saved_last_idx = 0;
358+
static int saved_no_hlsearch = 0;
359+
357360
/*
358361
* Save and restore the search pattern for incremental highlight search
359362
* feature.
@@ -575,7 +578,7 @@ set_last_search_pat(
575578
saved_spats[idx].pat = NULL;
576579
else
577580
saved_spats[idx].pat = vim_strsave(spats[idx].pat);
578-
saved_last_idx = last_idx;
581+
saved_spats_last_idx = last_idx;
579582
}
580583
# ifdef FEAT_SEARCH_EXTRA
581584
/* If 'hlsearch' set and search pat changed: need redraw. */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
556,
795797
/**/
796798
555,
797799
/**/

0 commit comments

Comments
 (0)