From 6e55d99f433b5da7b3aeeb5585b663bf9bd22cd2 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 18 Sep 2016 17:29:42 +0200 Subject: vim-patch:7.4.1671 Problem: When help exists in multiple languages, adding @ab while "ab" is the default help language is unnecessary. Solution: Leave out "@ab" when not needed. (Ken Takata) https://github.com/vim/vim/commit/61264d99692803eec76a171916ab9720c75536b0 --- src/nvim/ex_getln.c | 45 +++++++++++++++++++++++++++++++-------------- src/nvim/version.c | 2 +- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1a97dc3d6f..7e6bf862d7 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3669,27 +3669,44 @@ expand_cmdline ( return EXPAND_OK; } -/* - * Cleanup matches for help tags: remove "@en" if "en" is the only language. - */ - +// Cleanup matches for help tags: +// Remove "@ab" if the top of 'helplang' is "ab" and the language of the first +// tag matches it. Otherwise remove "@en" if "en" is the only language. static void cleanup_help_tags(int num_file, char_u **file) { - int i, j; - int len; + char_u buf[4]; + char_u *p = buf; + + if (p_hlg[0] != NUL) { + *p++ = '@'; + *p++ = p_hlg[0]; + *p++ = p_hlg[1]; + } + *p = NUL; - for (i = 0; i < num_file; ++i) { - len = (int)STRLEN(file[i]) - 3; - if (len > 0 && 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". */ - for (j = 0; j < num_file; ++j) + for (int i = 0; i < num_file; i++) { + int len = (int)STRLEN(file[i]) - 3; + if (len <= 0) { + continue; + } + if (i == 0 && STRCMP(file[i] + len, buf) == 0) { + file[i][len] = NUL; + break; + } else 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". + int j; + for (j = 0; j < num_file; j++) { if (j != i && (int)STRLEN(file[j]) == len + 3 - && STRNCMP(file[i], file[j], len + 1) == 0) + && STRNCMP(file[i], file[j], len + 1) == 0) { break; - if (j == num_file) + } + } + if (j == num_file) { file[i][len] = NUL; + break; + } } } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 685a2a843b..24c3d4eb5b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -772,7 +772,7 @@ static int included_patches[] = { // 1674 NA 1673, // 1672 NA - // 1671, + 1671, // 1670, // 1669 NA // 1668 NA -- cgit From 641d4242904f4a9691bd7933beaf90f3cce81d97 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 18 Sep 2016 21:52:30 +0200 Subject: vim-patch:7.4.1818 Problem: Help completion adds @en to all matches except the first one. Solution: Remove "break", go over all items. https://github.com/vim/vim/commit/89c79b99328b66f77f1d12dc8c6701dfe2c57f15 --- src/nvim/ex_getln.c | 15 +++++++-------- src/nvim/version.c | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7e6bf862d7..b098f7d4ee 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2548,10 +2548,9 @@ static void cmdline_del(int from) ccline.cmdpos = from; } -/* - * this function is called when the screen size changes and with incremental - * search - */ +// This function is called when the screen size changes and with incremental +// search and in other situations where the command line may have been +// overwritten. void redrawcmdline(void) { if (cmd_silent) @@ -3677,7 +3676,7 @@ static void cleanup_help_tags(int num_file, char_u **file) char_u buf[4]; char_u *p = buf; - if (p_hlg[0] != NUL) { + if (p_hlg[0] != NUL && (p_hlg[0] != 'e' || p_hlg[1] != 'n')) { *p++ = '@'; *p++ = p_hlg[0]; *p++ = p_hlg[1]; @@ -3689,9 +3688,9 @@ static void cleanup_help_tags(int num_file, char_u **file) if (len <= 0) { continue; } - if (i == 0 && STRCMP(file[i] + len, buf) == 0) { + if (STRCMP(file[i] + len, buf) == 0) { + // remove the default language file[i][len] = NUL; - break; } else 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". @@ -3704,8 +3703,8 @@ static void cleanup_help_tags(int num_file, char_u **file) } } if (j == num_file) { + // item only exists with @en, remove it file[i][len] = NUL; - break; } } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 24c3d4eb5b..2f091ffc7a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -623,7 +623,7 @@ static int included_patches[] = { // 1821, // 1820, // 1819 NA - // 1818, + 1818, // 1817 NA // 1816, // 1815, -- cgit From 9114790c4ce73d7f2eae0a1a06a7ced02ab86cf0 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 25 Sep 2016 21:40:37 +0200 Subject: vim-patch:7.4.1820 Problem: Removing language from help tags too often. Solution: Only remove @en when not needed. (Hirohito Higashi) https://github.com/vim/vim/commit/9ccaae04c6f263e6db14fc403bca2404a7871114 --- src/nvim/ex_getln.c | 18 ++++-- src/nvim/testdir/test_help_tagjump.vim | 115 +++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 130 insertions(+), 5 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b098f7d4ee..4c997844ea 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3688,10 +3688,7 @@ static void cleanup_help_tags(int num_file, char_u **file) 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". int j; @@ -3708,6 +3705,19 @@ static void cleanup_help_tags(int num_file, char_u **file) } } } + + if (*buf != NUL) { + for (int i = 0; i < num_file; i++) { + int 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; + } + } + } } /* diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 42f8391aba..4e09e1f56b 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -48,3 +48,118 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*{address}\*') 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("\", cnt) . "'\let str='\", '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: diff --git a/src/nvim/version.c b/src/nvim/version.c index 2f091ffc7a..41e295f65e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -621,7 +621,7 @@ static int included_patches[] = { // 1823, // 1822 NA // 1821, - // 1820, + 1820, // 1819 NA 1818, // 1817 NA -- cgit From b6f8c35cf7d88b0fb23e12f51f1d032f030ec845 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 25 Sep 2016 22:51:43 +0200 Subject: vim-patch:7.4.1821 Problem: Test fails on MS-Windows. Solution: Sort the completion results. https://github.com/vim/vim/commit/4ed6b2e2d7fd5959fb9b9f608935d47305c4bbe4 --- src/nvim/testdir/test_help_tagjump.vim | 20 ++++++++++---------- src/nvim/version.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 4e09e1f56b..cc1c81c7f6 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -124,36 +124,36 @@ func Test_help_complete() 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) + call assert_equal(sort(['h test-col@en', 'h test-col@ab', + \ 'h test-char@en', 'h test-char@ab']), sort(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) + call assert_equal(sort(['h test-col', 'h test-col@en', + \ 'h test-char', 'h test-char@en']), sort(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', + call assert_equal(sort(['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) + \ 'h test-char@ab', 'h test-char@ja']), sort(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', + call assert_equal(sort(['h test-col', 'h test-col@en', \ 'h test-col@ja', 'h test-char', - \ 'h test-char@en', 'h test-char@ja'], list) + \ 'h test-char@en', 'h test-char@ja']), sort(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', + call assert_equal(sort(['h test-col', 'h test-col@ja', \ 'h test-col@en', 'h test-char', - \ 'h test-char@ja', 'h test-char@en'], list) + \ 'h test-char@ja', 'h test-char@en']), sort(list)) endif catch call assert_exception('X') diff --git a/src/nvim/version.c b/src/nvim/version.c index 41e295f65e..657afdd5e0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -620,7 +620,7 @@ static int included_patches[] = { // 1824 NA // 1823, // 1822 NA - // 1821, + 1821, 1820, // 1819 NA 1818, -- cgit