Mercurial > vim
changeset 8485:675ec6cc9021 v7.4.1533
commit https://github.com/vim/vim/commit/74c5bbf13435a7ab1e3461078bbcb1200f0451e1
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 10 22:19:53 2016 +0100
patch 7.4.1533
Problem: Using feedkeys() with an empty string disregards 'x' option.
Solution: Make 'x' work with an empty string. (Thinca)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 10 Mar 2016 22:30:05 +0100 |
parents | 4b90a960d7a7 |
children | 5ede4fe1aed5 |
files | src/eval.c src/testdir/test_alot.vim src/testdir/test_feedkeys.vim src/version.c |
diffstat | 4 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -11839,24 +11839,25 @@ f_feedkeys(typval_T *argvars, typval_T * 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); - for ( ; *flags != NUL; ++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; - } - } - } - + + if (argvars[1].v_type != VAR_UNKNOWN) + { + flags = get_tv_string_buf(&argvars[1], nbuf); + for ( ; *flags != NUL; ++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; + } + } + } + + 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);
--- 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
new file mode 100644 --- /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