From d4cc4e0871664cdf66d69237e2af671e903d8e80 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 Aug 2018 23:18:58 -0400 Subject: [PATCH 1/7] vim-patch:8.0.0998: strange error when using K while only spaces are selected Problem: Strange error when using K while only spaces are selected. (Christian J. Robinson) Solution: Check for blank argument. https://github.com/vim/vim/commit/a4f99f5a8b827162a26ca4e4d59f4f224503398a --- src/nvim/normal.c | 4 ++++ src/nvim/testdir/test_help.vim | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 0bf93ee001..09444ace0f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4771,6 +4771,10 @@ static void nv_ident(cmdarg_T *cap) assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty. bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0); + if (kp_help && *skipwhite(ptr) == NUL) { + EMSG(_(e_noident)); // found white space only + return; + } size_t buf_size = n * 2 + 30 + STRLEN(kp); char *buf = xmalloc(buf_size); buf[0] = NUL; diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 26edc16107..e7bd602dbc 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -13,4 +13,21 @@ endfunc func Test_help_errors() call assert_fails('help doesnotexist', 'E149:') call assert_fails('help!', 'E478:') + + new + set keywordprg=:help + call setline(1, " ") + call assert_fails('normal VK', 'E349:') + bwipe! +endfunc + +func Test_help_keyword() + new + set keywordprg=:help + call setline(1, " Visual ") + normal VK + call assert_match('^Visual mode', getline('.')) + call assert_equal('help', &ft) + close + bwipe! endfunc From 5c90bbae2aad0c3129ed8efa0f1b03980f7f28a3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 27 Aug 2018 10:14:57 -0400 Subject: [PATCH 2/7] vim-patch:8.0.1383: local additions in help skips some files Problem: Local additions in help skips some files. (joshklod) Solution: Check the base file name length equals. https://github.com/vim/vim/commit/35c5e8155da797f14124d98fdc6189067b965688 --- src/nvim/ex_cmds.c | 10 +++++----- src/nvim/testdir/test_help.vim | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ca975ee02a..78f422f211 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5017,11 +5017,9 @@ void fix_help_buffer(void) const char_u *const f1 = fnames[i1]; const char_u *const f2 = fnames[i2]; const char_u *const t1 = path_tail(f1); - if (fnamencmp(f1, f2, t1 - f1) != 0) { - continue; - } + const char_u *const t2 = path_tail(f2); const char_u *const e1 = STRRCHR(t1, '.'); - const char_u *const e2 = STRRCHR(path_tail(f2), '.'); + const char_u *const e2 = STRRCHR(t2, '.'); if (e1 == NULL || e2 == NULL) { continue; } @@ -5032,8 +5030,10 @@ void fix_help_buffer(void) fnames[i1] = NULL; continue; } - if (fnamencmp(f1, f2, e1 - f1) != 0) + if (e1 - f1 != e2 - f2 + || fnamencmp(f1, f2, e1 - f1) != 0) { continue; + } if (fnamecmp(e1, ".txt") == 0 && fnamecmp(e2, fname + 4) == 0) { /* use .abx instead of .txt */ diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index e7bd602dbc..ed3181564c 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -31,3 +31,22 @@ func Test_help_keyword() close bwipe! endfunc + +func Test_help_local_additions() + call mkdir('Xruntime/doc', 'p') + call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt') + call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') + let rtp_save = &rtp + set rtp+=./Xruntime + help + 1 + call search('mydoc.txt') + call assert_equal('|mydoc.txt| my awesome doc', getline('.')) + 1 + call search('mydoc-ext.txt') + call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.')) + close + + call delete('Xruntime', 'rf') + let &rtp = rtp_save +endfunc From 24b16ed35e402e6389ca00753343ac93c0949a02 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 27 Aug 2018 10:34:40 -0400 Subject: [PATCH 3/7] vim-patch:8.1.0231: :help -? goes to help for -+ Problem: :help -? goes to help for -+. Solution: Add -? to list of special cases. (Hirohito Higashi) https://github.com/vim/vim/commit/a5bc38b8c16be93bac900137a5837585006cc8a4 --- src/nvim/ex_cmds.c | 4 ++-- src/nvim/testdir/test_help_tagjump.vim | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 78f422f211..8971c0c16c 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4688,7 +4688,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la static char *(mtable[]) = {"*", "g*", "[*", "]*", "/*", "/\\*", "\"*", "**", "/\\(\\)", "/\\%(\\)", - "?", ":?", "?", "g?", "g?g?", "g??", + "?", ":?", "-?", "?", "g?", "g?g?", "g??", "/\\?", "/\\z(\\)", "\\=", ":s\\=", "[count]", "[quotex]", "[range]", ":[range]", @@ -4698,7 +4698,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la static char *(rtable[]) = {"star", "gstar", "[star", "]star", "/star", "/\\\\star", "quotestar", "starstar", "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "?", "g?", "g?g?", "g??", + "?", ":?", "-?", "?", "g?", "g?g?", "g??", "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", "\\[count]", "\\[quotex]", "\\[range]", ":\\[range]", diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 4d4a902031..09724066b0 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -38,6 +38,11 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*:?\*') helpclose + help -? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*-?\*') + helpclose + help FileW*Post call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*FileWritePost\*') From 106b308ed4c99b1f2397ebd106974e07f934a9f8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 27 Aug 2018 11:24:33 -0400 Subject: [PATCH 4/7] vim-patch:8.0.1792: MS-Windows users expect -? to work like --help Problem: MS-Windows users expect -? to work like --help. Solution: Add -?. (Christian Brabandt, closes vim/vim#2867) https://github.com/vim/vim/commit/c3e81694fca484ebabd99f3637bd83b9ee2dd50a Include runtime/ changes from https://github.com/vim/vim/commit/85eee130f44a2201d88ca2aeff0af3b11dd75fa9 to pass 8.1.0231 tests. --- runtime/doc/starting.txt | 3 ++- src/nvim/main.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index c9ce2b9dc1..3440131642 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -76,7 +76,8 @@ The option arguments may be given in any order. Single-letter options can be combined after one dash. There can be no option arguments after the "--" argument. ---help *-h* *--help* +--help *-h* *--help* *-?* +-? -h Give usage (help) message and exit. See |info-message| about capturing the text. diff --git a/src/nvim/main.c b/src/nvim/main.c index af7c194edc..ab8b33aa12 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -892,6 +892,7 @@ static void command_line_scan(mparm_T *parmp) set_option_value("rl", 1L, NULL, 0); break; } + case '?': // "-?" give help message (for MS-Windows) case 'h': { // "-h" give help message usage(); mch_exit(0); From 9d7dc49db133cabebc3b6017830020163526c533 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 27 Aug 2018 19:23:40 -0400 Subject: [PATCH 5/7] vim-patch:8.1.0235: more help tags that jump to the wrong location Problem: More help tags that jump to the wrong location. Solution: Add more exceptions and a table for "expr-" tags. (Hirohito Higashi) https://github.com/vim/vim/commit/3bf5e6a4c8eb84b44437d6148428565d44783eed --- src/nvim/ex_cmds.c | 35 ++++++++++++++++++-------- src/nvim/testdir/test_help_tagjump.vim | 23 +++++++++++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8971c0c16c..7538e353c4 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4688,7 +4688,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la static char *(mtable[]) = {"*", "g*", "[*", "]*", "/*", "/\\*", "\"*", "**", "/\\(\\)", "/\\%(\\)", - "?", ":?", "-?", "?", "g?", "g?g?", "g??", + "?", ":?", "?", "g?", "g?g?", "g??", + "-?", "q?", "v_g?", "/\\?", "/\\z(\\)", "\\=", ":s\\=", "[count]", "[quotex]", "[range]", ":[range]", @@ -4698,26 +4699,40 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la static char *(rtable[]) = {"star", "gstar", "[star", "]star", "/star", "/\\\\star", "quotestar", "starstar", "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "-?", "?", "g?", "g?g?", "g??", + "?", ":?", "?", "g?", "g?g?", "g??", + "-?", "q?", "v_g?", "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", "\\[count]", "\\[quotex]", "\\[range]", ":\\[range]", "\\[pattern]", "\\\\bar", "/\\\\%\\$", "s/\\\\\\~", "s/\\\\U", "s/\\\\L", "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; + static char *(expr_table[]) = {"!=?", "!~?", "<=?", "=?", ">?", "is?", "isnot?"}; int flags; d = IObuff; /* assume IObuff is long enough! */ - /* - * Recognize a few exceptions to the rule. Some strings that contain '*' - * with "star". Otherwise '*' is recognized as a wildcard. - */ - for (i = (int)ARRAY_SIZE(mtable); --i >= 0; ) - if (STRCMP(arg, mtable[i]) == 0) { - STRCPY(d, rtable[i]); - break; + if (STRNICMP(arg, "expr-", 5) == 0) { + // When the string starting with "expr-" and containing '?' and matches + // the table, it is taken literally. Otherwise '?' is recognized as a + // wildcard. + for (i = (int)ARRAY_SIZE(expr_table); --i >= 0; ) { + if (STRCMP(arg + 5, expr_table[i]) == 0) { + STRCPY(d, arg); + break; + } } + } else { + // Recognize a few exceptions to the rule. Some strings that contain + // '*' with "star". Otherwise '*' is recognized as a wildcard. + for (i = (int)ARRAY_SIZE(mtable); --i >= 0; ) { + if (STRCMP(arg, mtable[i]) == 0) { + STRCPY(d, rtable[i]); + break; + } + } + } if (i < 0) { /* no match in table */ /* Replace "\S" with "/\\S", etc. Otherwise every tag is matched. diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 09724066b0..c873487b92 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -38,11 +38,34 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*:?\*') helpclose + help q? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*q?\*') + call assert_true(expand('') == 'q?') + helpclose + help -? call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*-?\*') helpclose + help v_g? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*v_g?\*') + helpclose + + help expr-!=? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*expr-!=?\*') + call assert_true(expand('') == 'expr-!=?') + helpclose + + help expr-isnot? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*expr-isnot?\*') + call assert_true(expand('') == 'expr-isnot?') + helpclose + help FileW*Post call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*FileWritePost\*') From d29b71a1ded7daca90d8a770a25476295e95252f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 4 Sep 2018 21:22:30 -0400 Subject: [PATCH 6/7] ex_cmds: const variables in find_help_tags() keep_lang (param) is bool. --- src/nvim/ex_cmds.c | 22 +++++++++------------- src/nvim/ex_getln.c | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 7538e353c4..953fe012e4 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4675,15 +4675,13 @@ static int help_compare(const void *s1, const void *s2) return strcmp(p1, p2); } -/* - * Find all help tags matching "arg", sort them and return in matches[], with - * the number of matches in num_matches. - * The matches will be sorted with a "best" match algorithm. - * When "keep_lang" is TRUE try keeping the language of the current buffer. - */ -int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_lang) +// Find all help tags matching "arg", sort them and return in matches[], with +// the number of matches in num_matches. +// The matches will be sorted with a "best" match algorithm. +// When "keep_lang" is true try keeping the language of the current buffer. +int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches, + bool keep_lang) { - char_u *s, *d; int i; static char *(mtable[]) = {"*", "g*", "[*", "]*", "/*", "/\\*", "\"*", "**", @@ -4709,9 +4707,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; static char *(expr_table[]) = {"!=?", "!~?", "<=?", "=?", ">?", "is?", "isnot?"}; - int flags; - - d = IObuff; /* assume IObuff is long enough! */ + char_u *d = IObuff; // assume IObuff is long enough! if (STRNICMP(arg, "expr-", 5) == 0) { // When the string starting with "expr-" and containing '?' and matches @@ -4764,7 +4760,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la if (*arg == '(' && arg[1] == '\'') { arg++; } - for (s = arg; *s; s++) { + for (const char_u *s = arg; *s; s++) { // Replace "|" with "bar" and '"' with "quote" to match the name of // the tags for these commands. // Replace "*" with ".*" and "?" with "." to match command line @@ -4873,7 +4869,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la *matches = (char_u **)""; *num_matches = 0; - flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE; + int flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE; if (keep_lang) flags |= TAG_KEEP_LANG; if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 786e2cd12c..ff625d6dc9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4677,7 +4677,7 @@ ExpandFromContext ( /* With an empty argument we would get all the help tags, which is * very slow. Get matches for "help" instead. */ if (find_help_tags(*pat == NUL ? (char_u *)"help" : pat, - num_file, file, FALSE) == OK) { + num_file, file, false) == OK) { cleanup_help_tags(*num_file, *file); return OK; } From f3c895569d837befd28d4385bc9361b3cc700262 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 3 Sep 2018 00:50:54 -0400 Subject: [PATCH 7/7] lint --- src/nvim/ex_cmds.c | 57 ++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 953fe012e4..a9e9364dc3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4683,30 +4683,36 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches, bool keep_lang) { int i; - static char *(mtable[]) = {"*", "g*", "[*", "]*", - "/*", "/\\*", "\"*", "**", - "/\\(\\)", "/\\%(\\)", - "?", ":?", "?", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\?", "/\\z(\\)", "\\=", ":s\\=", - "[count]", "[quotex]", - "[range]", ":[range]", - "[pattern]", "\\|", "\\%$", - "s/\\~", "s/\\U", "s/\\L", - "s/\\1", "s/\\2", "s/\\3", "s/\\9"}; - static char *(rtable[]) = {"star", "gstar", "[star", "]star", - "/star", "/\\\\star", "quotestar", "starstar", - "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "?", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", - "\\[count]", "\\[quotex]", - "\\[range]", ":\\[range]", - "\\[pattern]", "\\\\bar", "/\\\\%\\$", - "s/\\\\\\~", "s/\\\\U", "s/\\\\L", - "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; - static char *(expr_table[]) = {"!=?", "!~?", "<=?", "=?", ">?", "is?", "isnot?"}; + static const char *(mtable[]) = { + "*", "g*", "[*", "]*", + "/*", "/\\*", "\"*", "**", + "/\\(\\)", "/\\%(\\)", + "?", ":?", "?", "g?", "g?g?", "g??", + "-?", "q?", "v_g?", + "/\\?", "/\\z(\\)", "\\=", ":s\\=", + "[count]", "[quotex]", + "[range]", ":[range]", + "[pattern]", "\\|", "\\%$", + "s/\\~", "s/\\U", "s/\\L", + "s/\\1", "s/\\2", "s/\\3", "s/\\9" + }; + static const char *(rtable[]) = { + "star", "gstar", "[star", "]star", + "/star", "/\\\\star", "quotestar", "starstar", + "/\\\\(\\\\)", "/\\\\%(\\\\)", + "?", ":?", "?", "g?", "g?g?", "g??", + "-?", "q?", "v_g?", + "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", + "\\[count]", "\\[quotex]", + "\\[range]", ":\\[range]", + "\\[pattern]", "\\\\bar", "/\\\\%\\$", + "s/\\\\\\~", "s/\\\\U", "s/\\\\L", + "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9" + }; + static const char *(expr_table[]) = { + "!=?", "!~?", "<=?", "=?", ">?", "is?", "isnot?" + }; char_u *d = IObuff; // assume IObuff is long enough! if (STRNICMP(arg, "expr-", 5) == 0) { @@ -4870,8 +4876,9 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches, *matches = (char_u **)""; *num_matches = 0; int flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE; - if (keep_lang) + if (keep_lang) { flags |= TAG_KEEP_LANG; + } if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK && *num_matches > 0) { /* Sort the matches found on the heuristic number that is after the