Hi Bram, Ken and list!
2016-5-7(Sat) 6:23:37 UTC+9 Bram Moolenaar:
> Ken Takata wrote:
>
> > 2016/5/6 Fri 2:14:57 UTC+9 Bram Moolenaar wrote:
> > > Ken Takata wrote:
> > >
> > > > 2016/5/6 Fri 0:19:06 UTC+9 Bram Moolenaar wrote:
> > > > > Patch 7.4.1818
> > > > > Problem: Help completion adds @en to all matches except the first
> > > > > one.
> > > > > Solution: Remove "break", go over all items.
> > > > > Files: src/ex_getln.c
> > > >
> > > > This patch has a problem when help files with multiple languages are
> > > > installed.
> > > > E.g. When @ja and @en are installed and 'helplang' is set to ja,
> > > >
> > > > :h screenrow()<C-D>
> > > > screenrow() screenrow()
> > > >
> > > > But this should be:
> > > >
> > > > :h screenrow()<C-D>
> > > > screenrow() screenrow()@en
> > > >
> > > > Or, when 'helplang' is not ja, this should be:
> > > >
> > > > :h screenrow()<C-D>
> > > > screenrow()@ja screenrow()@en
> > > >
> > > > @en should not be removed, when there is a same help item for another
> > > > language.
> > >
> > > I guess the problem is that it depends on the order, the check for a
> > > duplicate help tag in another language can happen after a language was
> > > already removed.
> >
> > Do you have any ideas to fix this?
> > I don't have it, but the following behavior is totally useless:
> >
> > :h screenrow()<C-D>
> > screenrow() screenrow()
>
> From the top of my head: First do the part that loops over all matches,
> do the other removing later.
I wrote a patch with a test.
Please check an attached patch.
>
> > > > BTW, I think that adding @en to all matches is harmless.
> > >
> > > Although this would be harmless, the @en should not be added when it's
> > > not needed, the matches look different from the actual help tag.
> >
> > Wasn't setting 'helplang' to en enough?
>
> It's initialized depending on the environment. It should not be needed
> for the user to set it.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 26fed59..9554dc7 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4519,12 +4519,7 @@ cleanup_help_tags(int num_file, char_u **file)
len = (int)STRLEN(file[i]) - 3;
if (len <= 0)
continue;
- if (STRCMP(file[i] + len, buf) == 0)
- {
- /* remove the default language */
- file[i][len] = NUL;
- }
- else if (STRCMP(file[i] + len, "@en") == 0)
+ if (STRCMP(file[i] + len, "@en") == 0)
{
/* Sorting on priority means the same item in another language may
* be anywhere. Search all items for a match up to the "@en". */
@@ -4538,6 +4533,18 @@ cleanup_help_tags(int num_file, char_u **file)
file[i][len] = NUL;
}
}
+
+ for (i = 0; i < num_file; ++i)
+ {
+ len = (int)STRLEN(file[i]) - 3;
+ if (len <= 0)
+ continue;
+ if (STRCMP(file[i] + len, buf) == 0)
+ {
+ /* remove the default language */
+ file[i][len] = NUL;
+ }
+ }
}
#endif
diff --git a/src/testdir/test_help_tagjump.vim b/src/testdir/test_help_tagjump.vim
index f486583..c3249d8 100644
--- a/src/testdir/test_help_tagjump.vim
+++ b/src/testdir/test_help_tagjump.vim
@@ -26,3 +26,118 @@ func Test_help_tagjump()
call assert_true(getline('.') =~ '\*arglistid()\*')
helpclose
endfunc
+
+let s:langs = ['en', 'ab', 'ja']
+
+func s:doc_config_setup()
+ let s:helpfile_save = &helpfile
+ let &helpfile="Xdir1/doc-en/doc/testdoc.txt"
+ let s:rtp_save = &rtp
+ let &rtp="Xdir1/doc-en"
+ if has('multi_lang')
+ let s:helplang_save=&helplang
+ endif
+
+ call delete('Xdir1', 'rf')
+
+ for lang in s:langs
+ if lang ==# 'en'
+ let tagfname = 'tags'
+ let docfname = 'testdoc.txt'
+ else
+ let tagfname = 'tags-' . lang
+ let docfname = 'testdoc.' . lang . 'x'
+ endif
+ let docdir = "Xdir1/doc-" . lang . "/doc"
+ call mkdir(docdir, "p")
+ call writefile(["\t*test-char*", "\t*test-col*"], docdir . '/' . docfname)
+ call writefile(["test-char\t" . docfname . "\t/*test-char*",
+ \ "test-col\t" . docfname . "\t/*test-col*"],
+ \ docdir . '/' . tagfname)
+ endfor
+endfunc
+
+func s:doc_config_teardown()
+ call delete('Xdir1', 'rf')
+
+ let &helpfile = s:helpfile_save
+ let &rtp = s:rtp_save
+ if has('multi_lang')
+ let &helplang = s:helplang_save
+ endif
+endfunc
+
+func s:get_cmd_compl_list(cmd)
+ let list = []
+ let str = ''
+ for cnt in range(1, 999)
+ call feedkeys(a:cmd . repeat("\<Tab>", cnt) . "'\<C-B>let str='\<CR>", 'tx')
+ if str ==# a:cmd[1:]
+ break
+ endif
+ call add(list, str)
+ endfor
+ return list
+endfunc
+
+func Test_help_complete()
+ try
+ let list = []
+ call s:doc_config_setup()
+
+ " 'helplang=' and help file lang is 'en'
+ if has('multi_lang')
+ set helplang=
+ endif
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-char'], list)
+
+ if has('multi_lang')
+ " 'helplang=ab' and help file lang is 'en'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-char'], list)
+
+ " 'helplang=' and help file lang is 'en' and 'ab'
+ set rtp+=Xdir1/doc-ab
+ set helplang=
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col@en', 'h test-col@ab',
+ \ 'h test-char@en', 'h test-char@ab'], list)
+
+ " 'helplang=ab' and help file lang is 'en' and 'ab'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-col@en',
+ \ 'h test-char', 'h test-char@en'], list)
+
+ " 'helplang=' and help file lang is 'en', 'ab' and 'ja'
+ set rtp+=Xdir1/doc-ja
+ set helplang=
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col@en', 'h test-col@ab',
+ \ 'h test-col@ja', 'h test-char@en',
+ \ 'h test-char@ab', 'h test-char@ja'], list)
+
+ " 'helplang=ab' and help file lang is 'en', 'ab' and 'ja'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-col@en',
+ \ 'h test-col@ja', 'h test-char',
+ \ 'h test-char@en', 'h test-char@ja'], list)
+
+ " 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja'
+ set helplang=ab,ja
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-col@ja',
+ \ 'h test-col@en', 'h test-char',
+ \ 'h test-char@ja', 'h test-char@en'], list)
+ endif
+ catch
+ call assert_exception('X')
+ finally
+ call s:doc_config_teardown()
+ endtry
+endfunc
+
+" vim: et sw=2: