Skip to content

Commit 9ccaae0

Browse files
committed
patch 7.4.1820
Problem: Removing language from help tags too often. Solution: Only remove @en when not needed. (Hirohito Higashi)
1 parent 827b165 commit 9ccaae0

3 files changed

Lines changed: 133 additions & 9 deletions

File tree

src/ex_getln.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4519,25 +4519,32 @@ cleanup_help_tags(int num_file, char_u **file)
45194519
len = (int)STRLEN(file[i]) - 3;
45204520
if (len <= 0)
45214521
continue;
4522-
if (STRCMP(file[i] + len, buf) == 0)
4523-
{
4524-
/* remove the default language */
4525-
file[i][len] = NUL;
4526-
}
4527-
else if (STRCMP(file[i] + len, "@en") == 0)
4522+
if (STRCMP(file[i] + len, "@en") == 0)
45284523
{
45294524
/* Sorting on priority means the same item in another language may
45304525
* be anywhere. Search all items for a match up to the "@en". */
45314526
for (j = 0; j < num_file; ++j)
4532-
if (j != i
4533-
&& (int)STRLEN(file[j]) == len + 3
4534-
&& STRNCMP(file[i], file[j], len + 1) == 0)
4527+
if (j != i && (int)STRLEN(file[j]) == len + 3
4528+
&& STRNCMP(file[i], file[j], len + 1) == 0)
45354529
break;
45364530
if (j == num_file)
45374531
/* item only exists with @en, remove it */
45384532
file[i][len] = NUL;
45394533
}
45404534
}
4535+
4536+
if (*buf != NUL)
4537+
for (i = 0; i < num_file; ++i)
4538+
{
4539+
len = (int)STRLEN(file[i]) - 3;
4540+
if (len <= 0)
4541+
continue;
4542+
if (STRCMP(file[i] + len, buf) == 0)
4543+
{
4544+
/* remove the default language */
4545+
file[i][len] = NUL;
4546+
}
4547+
}
45414548
}
45424549
#endif
45434550

src/testdir/test_help_tagjump.vim

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,118 @@ func Test_help_tagjump()
2626
call assert_true(getline('.') =~ '\*arglistid()\*')
2727
helpclose
2828
endfunc
29+
30+
let s:langs = ['en', 'ab', 'ja']
31+
32+
func s:doc_config_setup()
33+
let s:helpfile_save = &helpfile
34+
let &helpfile="Xdir1/doc-en/doc/testdoc.txt"
35+
let s:rtp_save = &rtp
36+
let &rtp="Xdir1/doc-en"
37+
if has('multi_lang')
38+
let s:helplang_save=&helplang
39+
endif
40+
41+
call delete('Xdir1', 'rf')
42+
43+
for lang in s:langs
44+
if lang ==# 'en'
45+
let tagfname = 'tags'
46+
let docfname = 'testdoc.txt'
47+
else
48+
let tagfname = 'tags-' . lang
49+
let docfname = 'testdoc.' . lang . 'x'
50+
endif
51+
let docdir = "Xdir1/doc-" . lang . "/doc"
52+
call mkdir(docdir, "p")
53+
call writefile(["\t*test-char*", "\t*test-col*"], docdir . '/' . docfname)
54+
call writefile(["test-char\t" . docfname . "\t/*test-char*",
55+
\ "test-col\t" . docfname . "\t/*test-col*"],
56+
\ docdir . '/' . tagfname)
57+
endfor
58+
endfunc
59+
60+
func s:doc_config_teardown()
61+
call delete('Xdir1', 'rf')
62+
63+
let &helpfile = s:helpfile_save
64+
let &rtp = s:rtp_save
65+
if has('multi_lang')
66+
let &helplang = s:helplang_save
67+
endif
68+
endfunc
69+
70+
func s:get_cmd_compl_list(cmd)
71+
let list = []
72+
let str = ''
73+
for cnt in range(1, 999)
74+
call feedkeys(a:cmd . repeat("\<Tab>", cnt) . "'\<C-B>let str='\<CR>", 'tx')
75+
if str ==# a:cmd[1:]
76+
break
77+
endif
78+
call add(list, str)
79+
endfor
80+
return list
81+
endfunc
82+
83+
func Test_help_complete()
84+
try
85+
let list = []
86+
call s:doc_config_setup()
87+
88+
" 'helplang=' and help file lang is 'en'
89+
if has('multi_lang')
90+
set helplang=
91+
endif
92+
let list = s:get_cmd_compl_list(":h test")
93+
call assert_equal(['h test-col', 'h test-char'], list)
94+
95+
if has('multi_lang')
96+
" 'helplang=ab' and help file lang is 'en'
97+
set helplang=ab
98+
let list = s:get_cmd_compl_list(":h test")
99+
call assert_equal(['h test-col', 'h test-char'], list)
100+
101+
" 'helplang=' and help file lang is 'en' and 'ab'
102+
set rtp+=Xdir1/doc-ab
103+
set helplang=
104+
let list = s:get_cmd_compl_list(":h test")
105+
call assert_equal(['h test-col@en', 'h test-col@ab',
106+
\ 'h test-char@en', 'h test-char@ab'], list)
107+
108+
" 'helplang=ab' and help file lang is 'en' and 'ab'
109+
set helplang=ab
110+
let list = s:get_cmd_compl_list(":h test")
111+
call assert_equal(['h test-col', 'h test-col@en',
112+
\ 'h test-char', 'h test-char@en'], list)
113+
114+
" 'helplang=' and help file lang is 'en', 'ab' and 'ja'
115+
set rtp+=Xdir1/doc-ja
116+
set helplang=
117+
let list = s:get_cmd_compl_list(":h test")
118+
call assert_equal(['h test-col@en', 'h test-col@ab',
119+
\ 'h test-col@ja', 'h test-char@en',
120+
\ 'h test-char@ab', 'h test-char@ja'], list)
121+
122+
" 'helplang=ab' and help file lang is 'en', 'ab' and 'ja'
123+
set helplang=ab
124+
let list = s:get_cmd_compl_list(":h test")
125+
call assert_equal(['h test-col', 'h test-col@en',
126+
\ 'h test-col@ja', 'h test-char',
127+
\ 'h test-char@en', 'h test-char@ja'], list)
128+
129+
" 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja'
130+
set helplang=ab,ja
131+
let list = s:get_cmd_compl_list(":h test")
132+
call assert_equal(['h test-col', 'h test-col@ja',
133+
\ 'h test-col@en', 'h test-char',
134+
\ 'h test-char@ja', 'h test-char@en'], list)
135+
endif
136+
catch
137+
call assert_exception('X')
138+
finally
139+
call s:doc_config_teardown()
140+
endtry
141+
endfunc
142+
143+
" vim: et sw=2:

src/version.c

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

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
1820,
756758
/**/
757759
1819,
758760
/**/

0 commit comments

Comments
 (0)