Skip to content

Commit 74c5bbf

Browse files
committed
patch 7.4.1533
Problem: Using feedkeys() with an empty string disregards 'x' option. Solution: Make 'x' work with an empty string. (Thinca)
1 parent 7bffaa9 commit 74c5bbf

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

src/eval.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11839,24 +11839,25 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
1183911839
return;
1184011840

1184111841
keys = get_tv_string(&argvars[0]);
11842-
if (*keys != NUL)
11842+
11843+
if (argvars[1].v_type != VAR_UNKNOWN)
1184311844
{
11844-
if (argvars[1].v_type != VAR_UNKNOWN)
11845+
flags = get_tv_string_buf(&argvars[1], nbuf);
11846+
for ( ; *flags != NUL; ++flags)
1184511847
{
11846-
flags = get_tv_string_buf(&argvars[1], nbuf);
11847-
for ( ; *flags != NUL; ++flags)
11848+
switch (*flags)
1184811849
{
11849-
switch (*flags)
11850-
{
11851-
case 'n': remap = FALSE; break;
11852-
case 'm': remap = TRUE; break;
11853-
case 't': typed = TRUE; break;
11854-
case 'i': insert = TRUE; break;
11855-
case 'x': execute = TRUE; break;
11856-
}
11850+
case 'n': remap = FALSE; break;
11851+
case 'm': remap = TRUE; break;
11852+
case 't': typed = TRUE; break;
11853+
case 'i': insert = TRUE; break;
11854+
case 'x': execute = TRUE; break;
1185711855
}
1185811856
}
11857+
}
1185911858

11859+
if (*keys != NUL || execute)
11860+
{
1186011861
/* Need to escape K_SPECIAL and CSI before putting the string in the
1186111862
* typeahead buffer. */
1186211863
keys_esc = vim_strsave_escape_csi(keys);

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source test_backspace_opt.vim
55
source test_cursor_func.vim
66
source test_delete.vim
77
source test_expand.vim
8+
source test_feedkeys.vim
89
source test_file_perm.vim
910
source test_glob2regpat.vim
1011
source test_join.vim

src/testdir/test_feedkeys.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
" Test feedkeys() function.
2+
3+
func Test_feedkeys_x_with_empty_string()
4+
new
5+
call feedkeys("ifoo\<Esc>")
6+
call assert_equal('', getline('.'))
7+
call feedkeys('', 'x')
8+
call assert_equal('foo', getline('.'))
9+
quit!
10+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1533,
746748
/**/
747749
1532,
748750
/**/

0 commit comments

Comments
 (0)