Mercurial > vim
changeset 7703:39251e981d1f v7.4.1150
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 21 23:32:32 2016 +0100
patch 7.4.1150
Problem: 'langmap' applies to the first character typed in Select mode.
(David Watson)
Solution: Check for SELECTMODE. (Christian Brabandt, closes https://github.com/vim/vim/issues/572)
Add the 'x' flag to feedkeys().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 21 Jan 2016 23:45:06 +0100 |
parents | c000f1b8a3ce |
children | 38de8d8f20a7 |
files | runtime/doc/eval.txt src/ex_docmd.c src/getchar.c src/normal.c src/proto/ex_docmd.pro src/testdir/Make_all.mak src/testdir/test_langmap.vim src/version.c |
diffstat | 8 files changed, 52 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -3099,6 +3099,11 @@ feedkeys({string} [, {mode}]) *feedke if coming from a mapping. This matters for undo, opening folds, etc. 'i' Insert the string instead of appending (see above). + 'x' Execute commands until typeahead is empty. This is + similar to using ":normal!". You can call feedkeys() + several times without 'x' and then one time with 'x' + (possibly with an empty {string}) to execute all the + typeahead. Return value is always 0. filereadable({file}) *filereadable()*
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -10226,17 +10226,26 @@ exec_normal_cmd(cmd, remap, silent) int remap; int silent; { + /* Stuff the argument into the typeahead buffer. */ + ins_typebuf(cmd, remap, 0, TRUE, silent); + exec_normal(FALSE); +} +#endif + +#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(FEAT_EVAL) \ + || defined(PROTO) +/* + * Execute normal_cmd() until there is no typeahead left. + */ + void +exec_normal(int was_typed) +{ oparg_T oa; - /* - * Stuff the argument into the typeahead buffer. - * Execute normal_cmd() until there is no typeahead left. - */ clear_oparg(&oa); finish_op = FALSE; - ins_typebuf(cmd, remap, 0, TRUE, silent); - while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0)) - && !got_int) + while ((!stuff_empty() || ((was_typed || !typebuf_typed()) + && typebuf.tb_len > 0)) && !got_int) { update_topline_cursor(); normal_cmd(&oa, TRUE); /* execute a Normal mode cmd */
--- a/src/getchar.c +++ b/src/getchar.c @@ -2149,7 +2149,8 @@ vgetorpeek(advance) else { LANGMAP_ADJUST(c1, - (State & (CMDLINE | INSERT)) == 0); + (State & (CMDLINE | INSERT)) == 0 + && get_real_state() != SELECTMODE); nolmaplen = 0; } #endif
--- a/src/normal.c +++ b/src/normal.c @@ -638,7 +638,7 @@ normal_cmd(oap, toplevel) * Get the command character from the user. */ c = safe_vgetc(); - LANGMAP_ADJUST(c, TRUE); + LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); /* * If a mapping was started in Visual or Select mode, remember the length
--- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -50,6 +50,7 @@ int vim_mkdir_emsg(char_u *name, int pro FILE *open_exfile(char_u *fname, int forceit, char *mode); void update_topline_cursor(void); void exec_normal_cmd(char_u *cmd, int remap, int silent); +void exec_normal(int was_typed); int find_cmdline_var(char_u *src, int *usedlen); char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped); char_u *expand_sfile(char_u *arg);
--- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \ test_cdo.res \ test_hardcopy.res \ test_increment.res \ + test_langmap.res \ test_perl.res \ test_quickfix.res \ test_syntax.res \
new file mode 100644 --- /dev/null +++ b/src/testdir/test_langmap.vim @@ -0,0 +1,24 @@ +" tests for 'langmap' + +func Test_langmap() + new + set langmap=}l,^x,%v + + call setline(1, ['abc']) + call feedkeys('gg0}^', 'tx') + call assert_equal('ac', getline(1)) + + " in Replace mode + " need silent! to avoid a delay when entering Insert mode + call setline(1, ['abcde']) + silent! call feedkeys("gg0lR%{z\<Esc>00", 'tx') + call assert_equal('a%{ze', getline(1)) + + " in Select mode + " need silent! to avoid a delay when entering Insert mode + call setline(1, ['abcde']) + silent! call feedkeys("gg0}%}\<C-G>}^\<Esc>00", 'tx') + call assert_equal('a}^de', getline(1)) + + quit! +endfunc