]> granicus.if.org Git - vim/commitdiff
patch 7.4.1533 v7.4.1533
authorBram Moolenaar <Bram@vim.org>
Thu, 10 Mar 2016 21:19:53 +0000 (22:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Mar 2016 21:19:53 +0000 (22:19 +0100)
Problem:    Using feedkeys() with an empty string disregards 'x' option.
Solution:   Make 'x' work with an empty string. (Thinca)

src/eval.c
src/testdir/test_alot.vim
src/testdir/test_feedkeys.vim [new file with mode: 0644]
src/version.c

index 825a606a7019634d949b6c58e0207a7e05c0219d..548c50b341651eafbdddf896755f1477cb7afd24 100644 (file)
@@ -11839,24 +11839,25 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
        return;
 
     keys = get_tv_string(&argvars[0]);
-    if (*keys != NUL)
+
+    if (argvars[1].v_type != VAR_UNKNOWN)
     {
-       if (argvars[1].v_type != VAR_UNKNOWN)
+       flags = get_tv_string_buf(&argvars[1], nbuf);
+       for ( ; *flags != NUL; ++flags)
        {
-           flags = get_tv_string_buf(&argvars[1], nbuf);
-           for ( ; *flags != NUL; ++flags)
+           switch (*flags)
            {
-               switch (*flags)
-               {
-                   case 'n': remap = FALSE; break;
-                   case 'm': remap = TRUE; break;
-                   case 't': typed = TRUE; break;
-                   case 'i': insert = TRUE; break;
-                   case 'x': execute = TRUE; break;
-               }
+               case 'n': remap = FALSE; break;
+               case 'm': remap = TRUE; break;
+               case 't': typed = TRUE; break;
+               case 'i': insert = TRUE; break;
+               case 'x': execute = TRUE; break;
            }
        }
+    }
 
+    if (*keys != NUL || execute)
+    {
        /* Need to escape K_SPECIAL and CSI before putting the string in the
         * typeahead buffer. */
        keys_esc = vim_strsave_escape_csi(keys);
index 857fe9abaa387b58cd3f40362cde47be9f6920dd..46be51584768911f92d949391bc20236411c9795 100644 (file)
@@ -5,6 +5,7 @@ source test_backspace_opt.vim
 source test_cursor_func.vim
 source test_delete.vim
 source test_expand.vim
+source test_feedkeys.vim
 source test_file_perm.vim
 source test_glob2regpat.vim
 source test_join.vim
diff --git a/src/testdir/test_feedkeys.vim b/src/testdir/test_feedkeys.vim
new file mode 100644 (file)
index 0000000..33cd589
--- /dev/null
@@ -0,0 +1,10 @@
+" Test feedkeys() function.
+
+func Test_feedkeys_x_with_empty_string()
+  new
+  call feedkeys("ifoo\<Esc>")
+  call assert_equal('', getline('.'))
+  call feedkeys('', 'x')
+  call assert_equal('foo', getline('.'))
+  quit!
+endfunc
index f82b1045b19196141fc538de09b2fc81a55c14c5..980f481f48a64af3d1d4a0630513b906f0bab448 100644 (file)
@@ -743,6 +743,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1533,
 /**/
     1532,
 /**/