diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2017-10-30 11:07:35 +0300 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2018-01-26 18:39:20 +0300 |
commit | 41394d82365b504c89bb4da9ed5adc11c6f619f0 (patch) | |
tree | c0632c87165c2a17e0a1df9b6de0d106565b9e0e /src/nvim/search.c | |
parent | 0a56bd33308d2c4ae45f261498d69cb44fbd13c8 (diff) | |
download | rneovim-41394d82365b504c89bb4da9ed5adc11c6f619f0.tar.gz rneovim-41394d82365b504c89bb4da9ed5adc11c6f619f0.tar.bz2 rneovim-41394d82365b504c89bb4da9ed5adc11c6f619f0.zip |
vim-patch:8.0.1238
Problem: Incremental search only shows one match.
Solution: When 'incsearch' and and 'hlsearch' are both set highlight all
matches. (haya14busa, closes vim/vim#2198)
https://github.com/vim/vim/commit/2e51d9a0972080b087d566608472928d5b7b35d7
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 0a266382ec..89a7752e9f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -96,6 +96,9 @@ static int lastc_bytelen = 1; /* >1 for multi-byte char */ /* copy of spats[], for keeping the search patterns while executing autocmds */ 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 saved_last_idx = 0; static int saved_no_hlsearch = 0; @@ -305,6 +308,33 @@ void free_search_patterns(void) #endif +/// Save and restore the search pattern for incremental highlight search +/// feature. +/// +/// It's similar but different from save_search_patterns() and +/// restore_search_patterns(), because the search pattern must be restored when +/// cancelling incremental searching even if it's called inside user functions. + void +save_last_search_pattern(void) +{ + saved_last_search_spat = spats[RE_SEARCH]; + if (spats[RE_SEARCH].pat != NULL) { + saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); + } + saved_last_idx = last_idx; + saved_no_hlsearch = no_hlsearch; +} + + void +restore_last_search_pattern(void) +{ + xfree(spats[RE_SEARCH].pat); + spats[RE_SEARCH] = saved_last_search_spat; + set_vv_searchforward(); + last_idx = saved_last_idx; + SET_NO_HLSEARCH(saved_no_hlsearch); +} + /* * Return TRUE when case should be ignored for search pattern "pat". * Uses the 'ignorecase' and 'smartcase' options. |