aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWei Huang <daviseago@gmail.com>2016-09-10 23:11:05 +0800
committerJustin M. Keyes <justinkz@gmail.com>2016-09-11 03:47:16 +0200
commitc4c29696245b9ef03935335f464dbaa2b46c2ba5 (patch)
tree9ebc093bc5cad06cab0c616e2136d89db45c3d48 /src
parentca65514a241b239e656cb87f0912bd9ba2e18ad8 (diff)
downloadrneovim-c4c29696245b9ef03935335f464dbaa2b46c2ba5.tar.gz
rneovim-c4c29696245b9ef03935335f464dbaa2b46c2ba5.tar.bz2
rneovim-c4c29696245b9ef03935335f464dbaa2b46c2ba5.zip
vim-patch:7.4.1533 #5320
Problem: Using feedkeys() with an empty string disregards 'x' option. Solution: Make 'x' work with an empty string. (Thinca) When integrating the patch to nvim, used same logic but different code based on nvim codebase. New test passed. https://github.com/vim/vim/commit/74c5bbf13435a7ab1e3461078bbcb1200f0451e1
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c8
-rw-r--r--src/nvim/eval.c11
-rw-r--r--src/nvim/testdir/test_alot.vim1
-rw-r--r--src/nvim/testdir/test_feedkeys.vim10
-rw-r--r--src/nvim/version.c2
5 files changed, 21 insertions, 11 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index bba7d7b9c2..b1572037cb 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -59,10 +59,6 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
bool typed = false;
bool execute = false;
- if (keys.size == 0) {
- return;
- }
-
for (size_t i = 0; i < mode.size; ++i) {
switch (mode.data[i]) {
case 'n': remap = false; break;
@@ -73,6 +69,10 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
}
}
+ if (keys.size == 0 && !execute) {
+ return;
+ }
+
char *keys_esc;
if (escape_csi) {
// Need to escape K_SPECIAL and CSI before putting the string in the
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ce04739ee4..e441f96e7e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8831,14 +8831,13 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
keys = get_tv_string(&argvars[0]);
- if (*keys != NUL) {
- if (argvars[1].v_type != VAR_UNKNOWN) {
- flags = get_tv_string_buf(&argvars[1], nbuf);
- }
- nvim_feedkeys(cstr_as_string((char *)keys),
- cstr_as_string((char *)flags), true);
+ if (argvars[1].v_type != VAR_UNKNOWN) {
+ flags = get_tv_string_buf(&argvars[1], nbuf);
}
+
+ nvim_feedkeys(cstr_as_string((char *)keys),
+ cstr_as_string((char *)flags), true);
}
/// "filereadable()" function
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index daf6f026ba..e5214971b4 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -3,6 +3,7 @@
source test_assign.vim
source test_cursor_func.vim
+source test_feedkeys.vim
source test_cmdline.vim
source test_menu.vim
source test_popup.vim
diff --git a/src/nvim/testdir/test_feedkeys.vim b/src/nvim/testdir/test_feedkeys.vim
new file mode 100644
index 0000000000..33cd58949d
--- /dev/null
+++ b/src/nvim/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/nvim/version.c b/src/nvim/version.c
index 95ca3f066f..37e3369a1a 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -745,7 +745,7 @@ static int included_patches[] = {
// 1536 NA
// 1535,
// 1534 NA
- // 1533,
+ 1533,
// 1532 NA
// 1531 NA
// 1530 NA