Last active
March 9, 2016 15:59
-
-
Save thinca/4d24fa3d5fa70d67ec56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Makefile b/src/Makefile | |
index f460a61..c1b1e3f 100644 | |
--- a/src/Makefile | |
+++ b/src/Makefile | |
@@ -2003,6 +2003,7 @@ test_arglist \ | |
test_cursor_func \ | |
test_delete \ | |
test_expand \ | |
+ test_feedkeys \ | |
test_glob2regpat \ | |
test_hardcopy \ | |
test_increment \ | |
diff --git a/src/eval.c b/src/eval.c | |
index 31c5ea2..394f2f4 100644 | |
--- a/src/eval.c | |
+++ b/src/eval.c | |
@@ -11818,24 +11818,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 857fe9a..46be515 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 0000000..33cd589 | |
--- /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
差分が若干みづらいですが、空文字列のときは一切処理をしていなかったのを、先に
{mode}
の処理を行い、x
がある場合は空文字列でも実行するようにした感じです。