]> granicus.if.org Git - vim/commitdiff
patch 8.1.0047: no completion for :unlet $VAR v8.1.0047
authorBram Moolenaar <Bram@vim.org>
Tue, 12 Jun 2018 15:03:39 +0000 (17:03 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 12 Jun 2018 15:03:39 +0000 (17:03 +0200)
Problem:    No completion for :unlet $VAR.
Solution:   Add completion. (Jason Franklin)

src/ex_docmd.c
src/testdir/test_unlet.vim
src/version.c

index 3bc86f5ac8754b66f0212155d258357b3b07df92..5229e0e73b099973e084543f1f8d7ccdc4b66e0c 100644 (file)
@@ -4056,8 +4056,16 @@ set_one_cmd_context(
        case CMD_unlet:
            while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL)
                arg = xp->xp_pattern + 1;
+
            xp->xp_context = EXPAND_USER_VARS;
            xp->xp_pattern = arg;
+
+           if (*xp->xp_pattern == '$')
+           {
+               xp->xp_context = EXPAND_ENV_VARS;
+               ++xp->xp_pattern;
+           }
+
            break;
 
        case CMD_function:
@@ -11277,7 +11285,10 @@ makeopens(
         * winminheight and winminwidth need to be set to avoid an error if the
         * user has set winheight or winwidth.
         */
-       if (put_line(fd, "set winminheight=1 winheight=1 winminwidth=1 winwidth=1") == FAIL)
+       if (put_line(fd, "set winminheight=0") == FAIL
+               || put_line(fd, "set winheight=1") == FAIL
+               || put_line(fd, "set winminwidth=0") == FAIL
+               || put_line(fd, "set winwidth=1") == FAIL)
            return FAIL;
        if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL)
            return FAIL;
index 6636f6d66b87ae607cacc70000bf77ef42fd1379..0a9f3c61b10ddc34e987e0bec17711f7a8248640 100644 (file)
@@ -45,3 +45,13 @@ func Test_unlet_env()
 
   unlet $MUST_NOT_BE_AN_ERROR
 endfunc
+
+func Test_unlet_complete()
+  let g:FOOBAR = 1
+  call feedkeys(":unlet g:FOO\t\n", 'tx')
+  call assert_true(!exists('g:FOOBAR'))
+
+  let $FOOBAR = 1
+  call feedkeys(":unlet $FOO\t\n", 'tx')
+  call assert_true(!exists('$FOOBAR') || empty($FOOBAR))
+endfunc
index 2ce060c50071bfe172e18424b7cfa6b76bc56e63..d290fda6fd2c88a94abfcc7d039f495ccb8b816e 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    47,
 /**/
     46,
 /**/