]> granicus.if.org Git - vim/commitdiff
patch 8.1.2113: ":help expr-!~?" only works after searching v8.1.2113
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Oct 2019 09:30:09 +0000 (11:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Oct 2019 09:30:09 +0000 (11:30 +0200)
Problem:    ":help expr-!~?" only works after searching.
Solution:   Escape "~" after "expr-". (closes #5015)

src/ex_cmds.c
src/testdir/test_help.vim
src/version.c

index 85e5be066df5ceaf1e4db8898d04a79310285cac..da01e9ddadcac137ec32a9682831857b23be5311 100644 (file)
@@ -5547,12 +5547,22 @@ find_help_tags(
     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.
+       // the table, it is taken literally (but ~ is escaped).  Otherwise '?'
+       // is recognized as a wildcard.
        for (i = (int)(sizeof(expr_table) / sizeof(char *)); --i >= 0; )
            if (STRCMP(arg + 5, expr_table[i]) == 0)
            {
-               STRCPY(d, arg);
+               int si = 0, di = 0;
+
+               for (;;)
+               {
+                   if (arg[si] == '~')
+                       d[di++] = '\\';
+                   d[di++] = arg[si];
+                   if (arg[si] == NUL)
+                       break;
+                   ++si;
+               }
                break;
            }
     }
index c550ff09e2f915c975420b88a3794fcacf9af46a..5dd937a935cd7303866d8790069d456b4b637f4d 100644 (file)
@@ -20,6 +20,12 @@ func Test_help_errors()
   bwipe!
 endfunc
 
+func Test_help_expr()
+  help expr-!~?
+  call assert_equal('eval.txt', expand('%:t'))
+  close
+endfunc
+
 func Test_help_keyword()
   new
   set keywordprg=:help
index eb1ad1fc264fbd4e2337f16adff2b81133ec1cb9..d37ee657d01712914795450cc59891001ca462ab 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2113,
 /**/
     2112,
 /**/