Skip to content

Commit c631f2d

Browse files
committed
patch 8.1.0315: helpgrep with language doesn't work properly
Problem: Helpgrep with language doesn't work properly. (Takuya Fujiwara) Solution: Check for the language earlier. (Hirohito Higashi)
1 parent 47ad565 commit c631f2d

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/quickfix.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,7 +5385,7 @@ ex_vimgrep(exarg_T *eap)
53855385
if (qf_restore_list(qi, save_qfid) == FAIL)
53865386
goto theend;
53875387

5388-
/* Jump to first match. */
5388+
// Jump to first match.
53895389
if (!qf_list_empty(qi, qi->qf_curlist))
53905390
{
53915391
if ((flags & VGR_NOJUMP) == 0)
@@ -6844,16 +6844,13 @@ hgr_search_files_in_dir(
68446844
/*
68456845
* Search for a pattern in all the help files in the 'runtimepath'
68466846
* and add the matches to a quickfix list.
6847-
* 'arg' is the language specifier. If supplied, then only matches in the
6847+
* 'lang' is the language specifier. If supplied, then only matches in the
68486848
* specified language are found.
68496849
*/
68506850
static void
6851-
hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *arg)
6851+
hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *lang)
68526852
{
68536853
char_u *p;
6854-
#ifdef FEAT_MULTI_LANG
6855-
char_u *lang;
6856-
#endif
68576854

68586855
#ifdef FEAT_MBYTE
68596856
vimconv_T vc;
@@ -6865,10 +6862,6 @@ hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *arg)
68656862
convert_setup(&vc, (char_u *)"utf-8", p_enc);
68666863
#endif
68676864

6868-
#ifdef FEAT_MULTI_LANG
6869-
/* Check for a specified language */
6870-
lang = check_help_lang(arg);
6871-
#endif
68726865

68736866
/* Go through all the directories in 'runtimepath' */
68746867
p = p_rtp;
@@ -6903,6 +6896,7 @@ ex_helpgrep(exarg_T *eap)
69036896
qf_info_T *qi = &ql_info;
69046897
int new_qi = FALSE;
69056898
char_u *au_name = NULL;
6899+
char_u *lang = NULL;
69066900

69076901
switch (eap->cmdidx)
69086902
{
@@ -6919,7 +6913,7 @@ ex_helpgrep(exarg_T *eap)
69196913
#endif
69206914
}
69216915

6922-
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
6916+
// Make 'cpoptions' empty, the 'l' flag should not be used here.
69236917
save_cpo = p_cpo;
69246918
p_cpo = empty_option;
69256919

@@ -6930,14 +6924,18 @@ ex_helpgrep(exarg_T *eap)
69306924
return;
69316925
}
69326926

6927+
#ifdef FEAT_MULTI_LANG
6928+
// Check for a specified language
6929+
lang = check_help_lang(eap->arg);
6930+
#endif
69336931
regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
69346932
regmatch.rm_ic = FALSE;
69356933
if (regmatch.regprog != NULL)
69366934
{
6937-
/* create a new quickfix list */
6935+
// create a new quickfix list
69386936
qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep));
69396937

6940-
hgr_search_in_rtp(qi, &regmatch, eap->arg);
6938+
hgr_search_in_rtp(qi, &regmatch, lang);
69416939

69426940
vim_regfree(regmatch.regprog);
69436941

@@ -6950,7 +6948,7 @@ ex_helpgrep(exarg_T *eap)
69506948
if (p_cpo == empty_option)
69516949
p_cpo = save_cpo;
69526950
else
6953-
/* Darn, some plugin changed the value. */
6951+
// Darn, some plugin changed the value.
69546952
free_string_option(save_cpo);
69556953

69566954
qf_list_changed(qi, qi->qf_curlist);
@@ -6973,8 +6971,8 @@ ex_helpgrep(exarg_T *eap)
69736971

69746972
if (eap->cmdidx == CMD_lhelpgrep)
69756973
{
6976-
/* If the help window is not opened or if it already points to the
6977-
* correct location list, then free the new location list. */
6974+
// If the help window is not opened or if it already points to the
6975+
// correct location list, then free the new location list.
69786976
if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi)
69796977
{
69806978
if (new_qi)

src/testdir/test_quickfix.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,20 @@ func Test_qf_tick()
30913091
call Xqftick_tests('l')
30923092
endfunc
30933093

3094+
" Test helpgrep with lang specifier
3095+
func Xtest_helpgrep_with_lang_specifier(cchar)
3096+
call s:setup_commands(a:cchar)
3097+
Xhelpgrep Vim@en
3098+
call assert_equal('help', &filetype)
3099+
call assert_notequal(0, g:Xgetlist({'nr' : '$'}).nr)
3100+
new | only
3101+
endfunc
3102+
3103+
func Test_helpgrep_with_lang_specifier()
3104+
call Xtest_helpgrep_with_lang_specifier('c')
3105+
call Xtest_helpgrep_with_lang_specifier('l')
3106+
endfunc
3107+
30943108
" The following test used to crash Vim.
30953109
" Open the location list window and close the regular window associated with
30963110
" the location list. When the garbage collection runs now, it incorrectly

src/version.c

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

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
315,
797799
/**/
798800
314,
799801
/**/

0 commit comments

Comments
 (0)