Skip to content

Commit 451fc7b

Browse files
committed
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)
1 parent 9d34d90 commit 451fc7b

File tree

9 files changed

+24
-22
lines changed

9 files changed

+24
-22
lines changed

src/ex_docmd.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12193,14 +12193,23 @@ ex_set(exarg_T *eap)
1219312193
(void)do_set(eap->arg, flags);
1219412194
}
1219512195

12196-
#ifdef FEAT_SEARCH_EXTRA
12196+
#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
12197+
void
12198+
set_no_hlsearch(int flag)
12199+
{
12200+
no_hlsearch = flag;
12201+
# ifdef FEAT_EVAL
12202+
set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls);
12203+
# endif
12204+
}
12205+
1219712206
/*
1219812207
* ":nohlsearch"
1219912208
*/
1220012209
static void
1220112210
ex_nohlsearch(exarg_T *eap UNUSED)
1220212211
{
12203-
SET_NO_HLSEARCH(TRUE);
12212+
set_no_hlsearch(TRUE);
1220412213
redraw_all_later(SOME_VALID);
1220512214
}
1220612215

src/ex_getln.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ getcmdline(
19761976
if (ccline.cmdlen == 0)
19771977
{
19781978
i = 0;
1979-
SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */
1979+
set_no_hlsearch(TRUE); /* turn off previous highlight */
19801980
redraw_all_later(SOME_VALID);
19811981
}
19821982
else
@@ -2045,7 +2045,7 @@ getcmdline(
20452045
/* Disable 'hlsearch' highlighting if the pattern matches
20462046
* everything. Avoids a flash when typing "foo\|". */
20472047
if (empty_pattern(ccline.cmdbuff))
2048-
SET_NO_HLSEARCH(TRUE);
2048+
set_no_hlsearch(TRUE);
20492049

20502050
validate_cursor();
20512051
/* May redraw the status line to show the cursor position. */

src/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8359,7 +8359,7 @@ set_bool_option(
83598359
/* when 'hlsearch' is set or reset: reset no_hlsearch */
83608360
else if ((int *)varp == &p_hls)
83618361
{
8362-
SET_NO_HLSEARCH(FALSE);
8362+
set_no_hlsearch(FALSE);
83638363
}
83648364
#endif
83658365

src/proto/ex_docmd.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void dialog_msg(char_u *buff, char *format, char_u *fname);
6666
char_u *get_behave_arg(expand_T *xp, int idx);
6767
char_u *get_messages_arg(expand_T *xp, int idx);
6868
char_u *get_mapclear_arg(expand_T *xp, int idx);
69+
void set_no_hlsearch(int flag);
6970
int get_pressedreturn(void);
7071
void set_pressedreturn(int val);
7172
/* vim: set ft=c : */

src/screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7945,7 +7945,7 @@ next_search_hl(
79457945
{
79467946
/* don't free regprog in the match list, it's a copy */
79477947
vim_regfree(shl->rm.regprog);
7948-
SET_NO_HLSEARCH(TRUE);
7948+
set_no_hlsearch(TRUE);
79497949
}
79507950
shl->rm.regprog = NULL;
79517951
shl->lnum = 0;

src/search.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ save_re_pat(int idx, char_u *pat, int magic)
293293
/* If 'hlsearch' set and search pat changed: need redraw. */
294294
if (p_hls)
295295
redraw_all_later(SOME_VALID);
296-
SET_NO_HLSEARCH(FALSE);
296+
set_no_hlsearch(FALSE);
297297
#endif
298298
}
299299
}
@@ -336,7 +336,7 @@ restore_search_patterns(void)
336336
spats[1] = saved_spats[1];
337337
#ifdef FEAT_SEARCH_EXTRA
338338
last_idx = saved_last_idx;
339-
SET_NO_HLSEARCH(saved_no_hlsearch);
339+
set_no_hlsearch(saved_no_hlsearch);
340340
#endif
341341
}
342342
}
@@ -387,7 +387,7 @@ restore_last_search_pattern(void)
387387
set_vv_searchforward();
388388
# endif
389389
last_idx = saved_last_idx;
390-
SET_NO_HLSEARCH(saved_no_hlsearch);
390+
set_no_hlsearch(saved_no_hlsearch);
391391
}
392392

393393
char_u *
@@ -1282,7 +1282,7 @@ do_search(
12821282
if (no_hlsearch && !(options & SEARCH_KEEP))
12831283
{
12841284
redraw_all_later(SOME_VALID);
1285-
SET_NO_HLSEARCH(FALSE);
1285+
set_no_hlsearch(FALSE);
12861286
}
12871287
#endif
12881288

@@ -5757,9 +5757,7 @@ read_viminfo_search_pattern(vir_T *virp, int force)
57575757
spats[idx].off.off = off;
57585758
#ifdef FEAT_SEARCH_EXTRA
57595759
if (setlast)
5760-
{
5761-
SET_NO_HLSEARCH(!hlsearch_on);
5762-
}
5760+
set_no_hlsearch(!hlsearch_on);
57635761
#endif
57645762
}
57655763
}

src/tag.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,9 +3409,7 @@ jumpto_tag(
34093409
#ifdef FEAT_SEARCH_EXTRA
34103410
/* restore no_hlsearch when keeping the old search pattern */
34113411
if (search_options)
3412-
{
3413-
SET_NO_HLSEARCH(save_no_hlsearch);
3414-
}
3412+
set_no_hlsearch(save_no_hlsearch);
34153413
#endif
34163414

34173415
/* Return OK if jumped to another file (at least we found the file!). */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1768,
764766
/**/
765767
1767,
766768
/**/

src/vim.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,12 +2458,6 @@ typedef enum {
24582458
/* Character used as separated in autoload function/variable names. */
24592459
#define AUTOLOAD_CHAR '#'
24602460

2461-
#ifdef FEAT_EVAL
2462-
# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls)
2463-
#else
2464-
# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag)
2465-
#endif
2466-
24672461
#ifdef FEAT_JOB_CHANNEL
24682462
# define MAX_OPEN_CHANNELS 10
24692463
#else

0 commit comments

Comments
 (0)