comparison src/search.c @ 12720:37c384802df4 v8.0.1238

patch 8.0.1238: incremental search only shows one match commit https://github.com/vim/vim/commit/2e51d9a0972080b087d566608472928d5b7b35d7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 29 16:40:30 2017 +0100 patch 8.0.1238: incremental search only shows one match Problem: Incremental search only shows one match. Solution: When 'incsearch' and and 'hlsearch' are both set highlight all matches. (haya14busa, closes #2198)
author Christian Brabandt <cb@256bit.org>
date Sun, 29 Oct 2017 16:45:04 +0100
parents 6d3584b60170
children 7749260f261c
comparison
equal deleted inserted replaced
12719:cd6ab105a71a 12720:37c384802df4
98 #endif 98 #endif
99 99
100 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) 100 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO)
101 /* copy of spats[], for keeping the search patterns while executing autocmds */ 101 /* copy of spats[], for keeping the search patterns while executing autocmds */
102 static struct spat saved_spats[2]; 102 static struct spat saved_spats[2];
103 #endif
104 # ifdef FEAT_SEARCH_EXTRA
105 /* copy of spats[RE_SEARCH], for keeping the search patterns while incremental
106 * searching */
107 static struct spat saved_last_search_spat;
103 static int saved_last_idx = 0; 108 static int saved_last_idx = 0;
104 # ifdef FEAT_SEARCH_EXTRA
105 static int saved_no_hlsearch = 0; 109 static int saved_no_hlsearch = 0;
106 # endif 110 # endif
107 #endif
108 111
109 static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */ 112 static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */
110 #ifdef FEAT_RIGHTLEFT 113 #ifdef FEAT_RIGHTLEFT
111 static int mr_pattern_alloced = FALSE; /* mr_pattern was allocated */ 114 static int mr_pattern_alloced = FALSE; /* mr_pattern was allocated */
112 #endif 115 #endif
327 { 330 {
328 if (--save_level == 0) 331 if (--save_level == 0)
329 { 332 {
330 vim_free(spats[0].pat); 333 vim_free(spats[0].pat);
331 spats[0] = saved_spats[0]; 334 spats[0] = saved_spats[0];
332 #if defined(FEAT_EVAL) 335 # if defined(FEAT_EVAL)
333 set_vv_searchforward(); 336 set_vv_searchforward();
334 #endif 337 # endif
335 vim_free(spats[1].pat); 338 vim_free(spats[1].pat);
336 spats[1] = saved_spats[1]; 339 spats[1] = saved_spats[1];
337 last_idx = saved_last_idx; 340 last_idx = saved_last_idx;
338 # ifdef FEAT_SEARCH_EXTRA 341 # ifdef FEAT_SEARCH_EXTRA
339 SET_NO_HLSEARCH(saved_no_hlsearch); 342 SET_NO_HLSEARCH(saved_no_hlsearch);
355 vim_free(mr_pattern); 358 vim_free(mr_pattern);
356 mr_pattern_alloced = FALSE; 359 mr_pattern_alloced = FALSE;
357 mr_pattern = NULL; 360 mr_pattern = NULL;
358 } 361 }
359 # endif 362 # endif
363 }
364 #endif
365
366 #ifdef FEAT_SEARCH_EXTRA
367 /*
368 * Save and restore the search pattern for incremental highlight search
369 * feature.
370 *
371 * It's similar but differnt from save_search_patterns() and
372 * restore_search_patterns(), because the search pattern must be restored when
373 * cannceling incremental searching even if it's called inside user functions.
374 */
375 void
376 save_last_search_pattern(void)
377 {
378 saved_last_search_spat = spats[RE_SEARCH];
379 if (spats[RE_SEARCH].pat != NULL)
380 saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat);
381 saved_last_idx = last_idx;
382 saved_no_hlsearch = no_hlsearch;
383 }
384
385 void
386 restore_last_search_pattern(void)
387 {
388 vim_free(spats[RE_SEARCH].pat);
389 spats[RE_SEARCH] = saved_last_search_spat;
390 # if defined(FEAT_EVAL)
391 set_vv_searchforward();
392 # endif
393 last_idx = saved_last_idx;
394 SET_NO_HLSEARCH(saved_no_hlsearch);
360 } 395 }
361 #endif 396 #endif
362 397
363 /* 398 /*
364 * Return TRUE when case should be ignored for search pattern "pat". 399 * Return TRUE when case should be ignored for search pattern "pat".