diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-02 15:56:29 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-02 18:40:56 -0400 |
commit | 07b209b1fec19d4e8d7e5390c664d582d6a3145c (patch) | |
tree | 3236faae42a071f619a24137e6be6b56734189d4 | |
parent | 6434a0bf99d1733a295844813db201d533e65883 (diff) | |
download | rneovim-07b209b1fec19d4e8d7e5390c664d582d6a3145c.tar.gz rneovim-07b209b1fec19d4e8d7e5390c664d582d6a3145c.tar.bz2 rneovim-07b209b1fec19d4e8d7e5390c664d582d6a3145c.zip |
vim-patch:8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Problem: SET_NO_HLSEARCH() used in a wrong way.
Solution: Make it a function. (suggested by Dominique Pelle,
closes vim/vim#2850)
https://github.com/vim/vim/commit/451fc7b954906069f1830a8092ad85616049a828
-rw-r--r-- | src/nvim/ex_docmd.c | 8 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/globals.h | 4 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/search.c | 10 | ||||
-rw-r--r-- | src/nvim/shada.c | 3 | ||||
-rw-r--r-- | src/nvim/tag.c | 9 | ||||
-rw-r--r-- | src/nvim/vim.h | 3 |
9 files changed, 24 insertions, 21 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b880ec4f6d..85ec4efd3a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9990,12 +9990,18 @@ static void ex_set(exarg_T *eap) (void)do_set(eap->arg, flags); } +void set_no_hlsearch(bool flag) +{ + no_hlsearch = flag; + set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls); +} + /* * ":nohlsearch" */ static void ex_nohlsearch(exarg_T *eap) { - SET_NO_HLSEARCH(TRUE); + set_no_hlsearch(true); redraw_all_later(SOME_VALID); } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 4f35555098..f00367d9ca 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1830,7 +1830,7 @@ static int command_line_changed(CommandLineState *s) // If there is no command line, don't do anything if (ccline.cmdlen == 0) { i = 0; - SET_NO_HLSEARCH(true); // turn off previous highlight + set_no_hlsearch(true); // turn off previous highlight redraw_all_later(SOME_VALID); } else { int search_flags = SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK; @@ -1888,7 +1888,7 @@ static int command_line_changed(CommandLineState *s) // Disable 'hlsearch' highlighting if the pattern matches // everything. Avoids a flash when typing "foo\|". if (empty_pattern(ccline.cmdbuff)) { - SET_NO_HLSEARCH(true); + set_no_hlsearch(true); } validate_cursor(); diff --git a/src/nvim/globals.h b/src/nvim/globals.h index ad321963fe..9a7b5425bf 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -862,8 +862,8 @@ EXTERN char_u wim_flags[4]; # define STL_IN_TITLE 2 EXTERN int stl_syntax INIT(= 0); -/* don't use 'hlsearch' temporarily */ -EXTERN int no_hlsearch INIT(= FALSE); +// don't use 'hlsearch' temporarily +EXTERN bool no_hlsearch INIT(= false); /* Page number used for %N in 'pageheader' and 'guitablabel'. */ EXTERN linenr_T printer_page_num; diff --git a/src/nvim/option.c b/src/nvim/option.c index d1753526a7..6eeeca5068 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3959,7 +3959,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, redraw_all_later(SOME_VALID); } else if ((int *)varp == &p_hls) { // when 'hlsearch' is set or reset: reset no_hlsearch - SET_NO_HLSEARCH(false); + set_no_hlsearch(false); } else if ((int *)varp == &curwin->w_p_scb) { // when 'scrollbind' is set: snapshot the current position to avoid a jump // at the end of normal_cmd() diff --git a/src/nvim/screen.c b/src/nvim/screen.c index b9469686b5..13eb088813 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5762,7 +5762,7 @@ next_search_hl ( if (shl == &search_hl) { // don't free regprog in the match list, it's a copy vim_regfree(shl->rm.regprog); - SET_NO_HLSEARCH(TRUE); + set_no_hlsearch(true); } shl->rm.regprog = NULL; shl->lnum = 0; diff --git a/src/nvim/search.c b/src/nvim/search.c index 26549208a8..7d1c19d68c 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -100,7 +100,7 @@ static struct spat saved_spats[2]; // searching static struct spat saved_last_search_spat; static int saved_last_idx = 0; -static int saved_no_hlsearch = 0; +static bool saved_no_hlsearch = false; static char_u *mr_pattern = NULL; // pattern used by search_regcomp() static int mr_pattern_alloced = false; // mr_pattern was allocated @@ -248,7 +248,7 @@ void save_re_pat(int idx, char_u *pat, int magic) /* If 'hlsearch' set and search pat changed: need redraw. */ if (p_hls) redraw_all_later(SOME_VALID); - SET_NO_HLSEARCH(FALSE); + set_no_hlsearch(false); } } @@ -281,7 +281,7 @@ void restore_search_patterns(void) free_spat(&spats[1]); spats[1] = saved_spats[1]; last_idx = saved_last_idx; - SET_NO_HLSEARCH(saved_no_hlsearch); + set_no_hlsearch(saved_no_hlsearch); } } @@ -330,7 +330,7 @@ void restore_last_search_pattern(void) spats[RE_SEARCH] = saved_last_search_spat; set_vv_searchforward(); last_idx = saved_last_idx; - SET_NO_HLSEARCH(saved_no_hlsearch); + set_no_hlsearch(saved_no_hlsearch); } char_u *last_search_pattern(void) @@ -1048,7 +1048,7 @@ int do_search( */ if (no_hlsearch && !(options & SEARCH_KEEP)) { redraw_all_later(SOME_VALID); - SET_NO_HLSEARCH(FALSE); + set_no_hlsearch(false); } /* diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 69e6d61464..50f8990cf6 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -32,6 +32,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" +#include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/search.h" #include "nvim/regexp.h" @@ -1274,7 +1275,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) if (cur_entry.data.search_pattern.is_last_used) { set_last_used_pattern( cur_entry.data.search_pattern.is_substitute_pattern); - SET_NO_HLSEARCH(!cur_entry.data.search_pattern.highlighted); + set_no_hlsearch(!cur_entry.data.search_pattern.highlighted); } // Do not free shada entry: its allocated memory was saved above. break; diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 88676abc2e..beee3c7594 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2310,7 +2310,6 @@ static int jumpto_tag( int retval = FAIL; int getfile_result = GETFILE_UNUSED; int search_options; - int save_no_hlsearch; win_T *curwin_save = NULL; char_u *full_fname = NULL; const bool old_KeyTyped = KeyTyped; // getting the file may reset it @@ -2453,9 +2452,9 @@ static int jumpto_tag( secure = 1; ++sandbox; save_magic = p_magic; - p_magic = FALSE; /* always execute with 'nomagic' */ - /* Save value of no_hlsearch, jumping to a tag is not a real search */ - save_no_hlsearch = no_hlsearch; + p_magic = false; // always execute with 'nomagic' + // Save value of no_hlsearch, jumping to a tag is not a real search + const bool save_no_hlsearch = no_hlsearch; /* * If 'cpoptions' contains 't', store the search pattern for the "n" @@ -2560,7 +2559,7 @@ static int jumpto_tag( --sandbox; /* restore no_hlsearch when keeping the old search pattern */ if (search_options) { - SET_NO_HLSEARCH(save_no_hlsearch); + set_no_hlsearch(save_no_hlsearch); } // Return OK if jumped to another file (at least we found the file!). diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 60737014b3..51f143a3d7 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -296,9 +296,6 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() #include "nvim/buffer_defs.h" // buffer and windows #include "nvim/ex_cmds_defs.h" // Ex command defines -# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \ - VV_HLSEARCH, !no_hlsearch && p_hls) - // Used for flags in do_in_path() #define DIP_ALL 0x01 // all matches, not just the first one #define DIP_DIR 0x02 // find directories instead of files |