vim-patch:8.2.0902: using searchcount() in 'statusline' causes an error

Problem:    Using searchcount() in 'statusline' causes an error.
Solution:   Avoid saving/restoring the search patten recursively.
            (closes vim/vim#6194)
442a85369f
This commit is contained in:
Jan Edmund Lazo
2020-09-12 19:26:56 -04:00
parent ce32545708
commit 4327fe8da5
2 changed files with 40 additions and 7 deletions

View File

@@ -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;