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.

74c5bbf134
This commit is contained in:
Wei Huang 2016-09-10 23:11:05 +08:00 committed by Justin M. Keyes
parent ca65514a24
commit c4c2969624
5 changed files with 21 additions and 11 deletions

View File

@ -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

View File

@ -8831,7 +8831,7 @@ 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);
}
@ -8839,7 +8839,6 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv, FunPtr fptr)
nvim_feedkeys(cstr_as_string((char *)keys),
cstr_as_string((char *)flags), true);
}
}
/// "filereadable()" function
static void f_filereadable(typval_T *argvars, typval_T *rettv, FunPtr fptr)

View File

@ -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

View File

@ -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

View File

@ -745,7 +745,7 @@ static int included_patches[] = {
// 1536 NA
// 1535,
// 1534 NA
// 1533,
1533,
// 1532 NA
// 1531 NA
// 1530 NA