summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-10 22:19:53 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-10 22:19:53 +0100
commit74c5bbf13435a7ab1e3461078bbcb1200f0451e1 (patch)
tree4904316d352323d5f26d923975d09eb0f13b96d5
parent7bffaa9f9b477969d85cef41adeadc4506373708 (diff)
downloadvim-git-74c5bbf13435a7ab1e3461078bbcb1200f0451e1.tar.gz
patch 7.4.1533v7.4.1533
Problem: Using feedkeys() with an empty string disregards 'x' option. Solution: Make 'x' work with an empty string. (Thinca)
-rw-r--r--src/eval.c25
-rw-r--r--src/testdir/test_alot.vim1
-rw-r--r--src/testdir/test_feedkeys.vim10
-rw-r--r--src/version.c2
4 files changed, 26 insertions, 12 deletions
diff --git a/src/eval.c b/src/eval.c
index 825a606a7..548c50b34 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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);
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index 857fe9aba..46be51584 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -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
index 000000000..33cd58949
--- /dev/null
+++ b/src/testdir/test_feedkeys.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index f82b1045b..980f481f4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1533,
+/**/
1532,
/**/
1531,