Skip to content

Commit 6dbf66a

Browse files
committed
patch 8.0.0116
Problem: When reading English help and using CTRl-] the language from 'helplang' is used. Solution: Make help tag jumps keep the language. (Tatsuki, test by Hirohito Higashi, closes #1249)
1 parent e3af763 commit 6dbf66a

3 files changed

Lines changed: 58 additions & 9 deletions

File tree

src/tag.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ do_tag(
742742
/* skip backslash used for escaping a command char or
743743
* a backslash */
744744
if (*p == '\\' && (*(p + 1) == *tagp.command
745-
|| *(p + 1) == '\\'))
745+
|| *(p + 1) == '\\'))
746746
++p;
747747

748748
if (*p == TAB)
@@ -1356,6 +1356,7 @@ find_tags(
13561356
char_u *help_lang_find = NULL; /* lang to be found */
13571357
char_u help_lang[3]; /* lang of current tags file */
13581358
char_u *saved_pat = NULL; /* copy of pat[] */
1359+
int is_txt = FALSE; /* flag of file extension */
13591360
#endif
13601361

13611362
pat_T orgpat; /* holds unconverted pattern info */
@@ -1388,7 +1389,7 @@ find_tags(
13881389
*/
13891390
switch (curbuf->b_tc_flags ? curbuf->b_tc_flags : tc_flags)
13901391
{
1391-
case TC_FOLLOWIC: break;
1392+
case TC_FOLLOWIC: break;
13921393
case TC_IGNORE: p_ic = TRUE; break;
13931394
case TC_MATCH: p_ic = FALSE; break;
13941395
case TC_FOLLOWSCS: p_ic = ignorecase(pat); break;
@@ -1476,6 +1477,15 @@ find_tags(
14761477
* When the tag file is case-fold sorted, it is either one or the other.
14771478
* Only ignore case when TAG_NOIC not used or 'ignorecase' set.
14781479
*/
1480+
#ifdef FEAT_MULTI_LANG
1481+
/* Set a flag if the file extension is .txt */
1482+
if ((flags & TAG_KEEP_LANG)
1483+
&& help_lang_find == NULL
1484+
&& curbuf->b_fname != NULL
1485+
&& (i = (int)STRLEN(curbuf->b_fname)) > 4
1486+
&& STRICMP(curbuf->b_fname + i - 4, ".txt") == 0)
1487+
is_txt = TRUE;
1488+
#endif
14791489
#ifdef FEAT_TAG_BINS
14801490
orgpat.regmatch.rm_ic = ((p_ic || !noic)
14811491
&& (findall || orgpat.headlen == 0 || !p_tbs));
@@ -1509,14 +1519,19 @@ find_tags(
15091519
#ifdef FEAT_MULTI_LANG
15101520
if (curbuf->b_help)
15111521
{
1512-
/* Prefer help tags according to 'helplang'. Put the
1513-
* two-letter language name in help_lang[]. */
1514-
i = (int)STRLEN(tag_fname);
1515-
if (i > 3 && tag_fname[i - 3] == '-')
1516-
STRCPY(help_lang, tag_fname + i - 2);
1517-
else
1522+
/* Keep en if the file extension is .txt*/
1523+
if (is_txt)
15181524
STRCPY(help_lang, "en");
1519-
1525+
else
1526+
{
1527+
/* Prefer help tags according to 'helplang'. Put the
1528+
* two-letter language name in help_lang[]. */
1529+
i = (int)STRLEN(tag_fname);
1530+
if (i > 3 && tag_fname[i - 3] == '-')
1531+
STRCPY(help_lang, tag_fname + i - 2);
1532+
else
1533+
STRCPY(help_lang, "en");
1534+
}
15201535
/* When searching for a specific language skip tags files
15211536
* for other languages. */
15221537
if (help_lang_find != NULL

src/testdir/test_help_tagjump.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,36 @@ func Test_help_complete()
141141
endtry
142142
endfunc
143143

144+
func Test_help_respect_current_file_lang()
145+
try
146+
let list = []
147+
call s:doc_config_setup()
148+
149+
if has('multi_lang')
150+
function s:check_help_file_ext(help_keyword, ext)
151+
exec 'help ' . a:help_keyword
152+
call assert_equal(a:ext, expand('%:e'))
153+
call feedkeys("\<C-]>", 'tx')
154+
call assert_equal(a:ext, expand('%:e'))
155+
pop
156+
helpclose
157+
endfunc
158+
159+
set rtp+=Xdir1/doc-ab
160+
set rtp+=Xdir1/doc-ja
161+
162+
set helplang=ab
163+
call s:check_help_file_ext('test-char', 'abx')
164+
call s:check_help_file_ext('test-char@ja', 'jax')
165+
set helplang=ab,ja
166+
call s:check_help_file_ext('test-char@ja', 'jax')
167+
call s:check_help_file_ext('test-char@en', 'txt')
168+
endif
169+
catch
170+
call assert_exception('X')
171+
finally
172+
call s:doc_config_teardown()
173+
endtry
174+
endfunc
175+
144176
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
116,
767769
/**/
768770
115,
769771
/**/

0 commit comments

Comments
 (0)