comparison src/search.c @ 27704:4c68fb88b73f v8.2.4378

patch 8.2.4378: incsearch HL broken when calling searchcount in 'tabLine' Commit: https://github.com/vim/vim/commit/6dd7424c7e6ab81998c29ca3526c41b75cfde5a1 Author: Christian Brabandt <cb@256bit.org> Date: Mon Feb 14 12:44:32 2022 +0000 patch 8.2.4378: incsearch HL broken when calling searchcount in 'tabLine' Problem: Incsearch highlight broken when calling searchcount() in 'tabLine' function. (Mirko Palmer) Solution: Save and restore the incsearch state. (Christian Brabandt, closes #9763, closes #9633)
author Bram Moolenaar <Bram@vim.org>
date Mon, 14 Feb 2022 13:45:02 +0100
parents 8dbdd68627bd
children c1d1639b52dd
comparison
equal deleted inserted replaced
27703:0d4c4c3ca0d0 27704:4c68fb88b73f
323 // searching 323 // searching
324 static spat_T saved_last_search_spat; 324 static spat_T saved_last_search_spat;
325 static int did_save_last_search_spat = 0; 325 static int did_save_last_search_spat = 0;
326 static int saved_last_idx = 0; 326 static int saved_last_idx = 0;
327 static int saved_no_hlsearch = 0; 327 static int saved_no_hlsearch = 0;
328 static int saved_search_match_endcol;
329 static int saved_search_match_lines;
328 330
329 /* 331 /*
330 * Save and restore the search pattern for incremental highlight search 332 * Save and restore the search pattern for incremental highlight search
331 * feature. 333 * feature.
332 * 334 *
366 # if defined(FEAT_EVAL) 368 # if defined(FEAT_EVAL)
367 set_vv_searchforward(); 369 set_vv_searchforward();
368 # endif 370 # endif
369 last_idx = saved_last_idx; 371 last_idx = saved_last_idx;
370 set_no_hlsearch(saved_no_hlsearch); 372 set_no_hlsearch(saved_no_hlsearch);
373 }
374
375 /*
376 * Save and restore the incsearch highlighting variables.
377 * This is required so that calling searchcount() at does not invalidate the
378 * incsearch highlighting.
379 */
380 static void
381 save_incsearch_state(void)
382 {
383 saved_search_match_endcol = search_match_endcol;
384 saved_search_match_lines = search_match_lines;
385 }
386
387 static void
388 restore_incsearch_state(void)
389 {
390 search_match_endcol = saved_search_match_endcol;
391 search_match_lines = saved_search_match_lines;
371 } 392 }
372 393
373 char_u * 394 char_u *
374 last_search_pattern(void) 395 last_search_pattern(void)
375 { 396 {
4180 } 4201 }
4181 } 4202 }
4182 } 4203 }
4183 4204
4184 save_last_search_pattern(); 4205 save_last_search_pattern();
4206 #ifdef FEAT_SEARCH_EXTRA
4207 save_incsearch_state();
4208 #endif
4185 if (pattern != NULL) 4209 if (pattern != NULL)
4186 { 4210 {
4187 if (*pattern == NUL) 4211 if (*pattern == NUL)
4188 goto the_end; 4212 goto the_end;
4189 vim_free(spats[last_idx].pat); 4213 vim_free(spats[last_idx].pat);
4200 dict_add_number(rettv->vval.v_dict, "incomplete", stat.incomplete); 4224 dict_add_number(rettv->vval.v_dict, "incomplete", stat.incomplete);
4201 dict_add_number(rettv->vval.v_dict, "maxcount", stat.last_maxcount); 4225 dict_add_number(rettv->vval.v_dict, "maxcount", stat.last_maxcount);
4202 4226
4203 the_end: 4227 the_end:
4204 restore_last_search_pattern(); 4228 restore_last_search_pattern();
4229 #ifdef FEAT_SEARCH_EXTRA
4230 restore_incsearch_state();
4231 #endif
4205 } 4232 }
4206 4233
4207 /* 4234 /*
4208 * Fuzzy string matching 4235 * Fuzzy string matching
4209 * 4236 *