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 #2850)
This commit is contained in:
Bram Moolenaar
2018-04-27 22:53:07 +02:00
parent 9d34d90210
commit 451fc7b954
9 changed files with 24 additions and 22 deletions

View File

@@ -12193,14 +12193,23 @@ ex_set(exarg_T *eap)
(void)do_set(eap->arg, flags); (void)do_set(eap->arg, flags);
} }
#ifdef FEAT_SEARCH_EXTRA #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
void
set_no_hlsearch(int flag)
{
no_hlsearch = flag;
# ifdef FEAT_EVAL
set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls);
# endif
}
/* /*
* ":nohlsearch" * ":nohlsearch"
*/ */
static void static void
ex_nohlsearch(exarg_T *eap UNUSED) ex_nohlsearch(exarg_T *eap UNUSED)
{ {
SET_NO_HLSEARCH(TRUE); set_no_hlsearch(TRUE);
redraw_all_later(SOME_VALID); redraw_all_later(SOME_VALID);
} }

View File

@@ -1976,7 +1976,7 @@ cmdline_changed:
if (ccline.cmdlen == 0) if (ccline.cmdlen == 0)
{ {
i = 0; i = 0;
SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */ set_no_hlsearch(TRUE); /* turn off previous highlight */
redraw_all_later(SOME_VALID); redraw_all_later(SOME_VALID);
} }
else else
@@ -2045,7 +2045,7 @@ cmdline_changed:
/* Disable 'hlsearch' highlighting if the pattern matches /* Disable 'hlsearch' highlighting if the pattern matches
* everything. Avoids a flash when typing "foo\|". */ * everything. Avoids a flash when typing "foo\|". */
if (empty_pattern(ccline.cmdbuff)) if (empty_pattern(ccline.cmdbuff))
SET_NO_HLSEARCH(TRUE); set_no_hlsearch(TRUE);
validate_cursor(); validate_cursor();
/* May redraw the status line to show the cursor position. */ /* May redraw the status line to show the cursor position. */

View File

@@ -8359,7 +8359,7 @@ set_bool_option(
/* when 'hlsearch' is set or reset: reset no_hlsearch */ /* when 'hlsearch' is set or reset: reset no_hlsearch */
else if ((int *)varp == &p_hls) else if ((int *)varp == &p_hls)
{ {
SET_NO_HLSEARCH(FALSE); set_no_hlsearch(FALSE);
} }
#endif #endif

View File

@@ -66,6 +66,7 @@ void dialog_msg(char_u *buff, char *format, char_u *fname);
char_u *get_behave_arg(expand_T *xp, int idx); char_u *get_behave_arg(expand_T *xp, int idx);
char_u *get_messages_arg(expand_T *xp, int idx); char_u *get_messages_arg(expand_T *xp, int idx);
char_u *get_mapclear_arg(expand_T *xp, int idx); char_u *get_mapclear_arg(expand_T *xp, int idx);
void set_no_hlsearch(int flag);
int get_pressedreturn(void); int get_pressedreturn(void);
void set_pressedreturn(int val); void set_pressedreturn(int val);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -7945,7 +7945,7 @@ next_search_hl(
{ {
/* don't free regprog in the match list, it's a copy */ /* don't free regprog in the match list, it's a copy */
vim_regfree(shl->rm.regprog); vim_regfree(shl->rm.regprog);
SET_NO_HLSEARCH(TRUE); set_no_hlsearch(TRUE);
} }
shl->rm.regprog = NULL; shl->rm.regprog = NULL;
shl->lnum = 0; shl->lnum = 0;

View File

@@ -293,7 +293,7 @@ save_re_pat(int idx, char_u *pat, int magic)
/* If 'hlsearch' set and search pat changed: need redraw. */ /* If 'hlsearch' set and search pat changed: need redraw. */
if (p_hls) if (p_hls)
redraw_all_later(SOME_VALID); redraw_all_later(SOME_VALID);
SET_NO_HLSEARCH(FALSE); set_no_hlsearch(FALSE);
#endif #endif
} }
} }
@@ -336,7 +336,7 @@ restore_search_patterns(void)
spats[1] = saved_spats[1]; spats[1] = saved_spats[1];
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
last_idx = saved_last_idx; last_idx = saved_last_idx;
SET_NO_HLSEARCH(saved_no_hlsearch); set_no_hlsearch(saved_no_hlsearch);
#endif #endif
} }
} }
@@ -387,7 +387,7 @@ restore_last_search_pattern(void)
set_vv_searchforward(); set_vv_searchforward();
# endif # endif
last_idx = saved_last_idx; last_idx = saved_last_idx;
SET_NO_HLSEARCH(saved_no_hlsearch); set_no_hlsearch(saved_no_hlsearch);
} }
char_u * char_u *
@@ -1282,7 +1282,7 @@ do_search(
if (no_hlsearch && !(options & SEARCH_KEEP)) if (no_hlsearch && !(options & SEARCH_KEEP))
{ {
redraw_all_later(SOME_VALID); redraw_all_later(SOME_VALID);
SET_NO_HLSEARCH(FALSE); set_no_hlsearch(FALSE);
} }
#endif #endif
@@ -5757,9 +5757,7 @@ read_viminfo_search_pattern(vir_T *virp, int force)
spats[idx].off.off = off; spats[idx].off.off = off;
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
if (setlast) if (setlast)
{ set_no_hlsearch(!hlsearch_on);
SET_NO_HLSEARCH(!hlsearch_on);
}
#endif #endif
} }
} }

View File

@@ -3409,9 +3409,7 @@ jumpto_tag(
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
/* restore no_hlsearch when keeping the old search pattern */ /* restore no_hlsearch when keeping the old search pattern */
if (search_options) if (search_options)
{ set_no_hlsearch(save_no_hlsearch);
SET_NO_HLSEARCH(save_no_hlsearch);
}
#endif #endif
/* Return OK if jumped to another file (at least we found the file!). */ /* Return OK if jumped to another file (at least we found the file!). */

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1768,
/**/ /**/
1767, 1767,
/**/ /**/

View File

@@ -2458,12 +2458,6 @@ typedef enum {
/* Character used as separated in autoload function/variable names. */ /* Character used as separated in autoload function/variable names. */
#define AUTOLOAD_CHAR '#' #define AUTOLOAD_CHAR '#'
#ifdef FEAT_EVAL
# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls)
#else
# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag)
#endif
#ifdef FEAT_JOB_CHANNEL #ifdef FEAT_JOB_CHANNEL
# define MAX_OPEN_CHANNELS 10 # define MAX_OPEN_CHANNELS 10
#else #else