From 40e7efe91cb60fc65eafece2c923a527d55de20d Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Sun, 22 May 2016 01:25:36 -0700 Subject: vim-patch:7.4.1150 Problem: 'langmap' applies to the first character typed in Select mode. (David Watson) Solution: Check for SELECTMODE. (Christian Brabandt, closes #572) Add the 'x' flag to feedkeys(). https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e --- src/nvim/ex_docmd.c | 20 +++++++++++--------- src/nvim/getchar.c | 3 ++- src/nvim/normal.c | 2 +- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_langmap.vim | 24 ++++++++++++++++++++++++ src/nvim/version.c | 2 +- 6 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 src/nvim/testdir/test_langmap.vim (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index dea52ee112..c0d5c37bc9 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7857,20 +7857,22 @@ static void ex_stopinsert(exarg_T *eap) * "remap" can be REMAP_NONE or REMAP_YES. */ void exec_normal_cmd(char_u *cmd, int remap, bool silent) +{ + // Stuff the argument into the typeahead buffer. + ins_typebuf(cmd, remap, 0, true, silent); + exec_normal(false); +} + +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) { + finish_op = false; + 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 */ + normal_cmd(&oa, true); // execute a Normal mode cmd } } diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index dbf0322d78..36fe393f18 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1757,7 +1757,8 @@ static int vgetorpeek(int advance) if (c1 == K_SPECIAL) nolmaplen = 2; else { - LANGMAP_ADJUST(c1, (State & (CMDLINE | INSERT)) == 0); + LANGMAP_ADJUST(c1, (State & (CMDLINE | INSERT)) == 0 + && get_real_state() != SELECTMODE); nolmaplen = 0; } /* First try buffer-local mappings. */ diff --git a/src/nvim/normal.c b/src/nvim/normal.c index cc604352e1..d4055ac1ef 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -974,7 +974,7 @@ static int normal_execute(VimState *state, int key) s->old_col = curwin->w_curswant; s->c = key; - LANGMAP_ADJUST(s->c, true); + LANGMAP_ADJUST(s->c, get_real_state() != SELECTMODE); // If a mapping was started in Visual or Select mode, remember the length // of the mapping. This is used below to not return to Insert mode for as diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index b06efc9ffb..b9ec1cfb2c 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -38,6 +38,7 @@ SCRIPTS := \ NEW_TESTS = \ test_cursor_func.res \ test_help_tagjump.res \ + test_langmap.res \ test_menu.res \ test_syntax.res \ test_timers.res \ diff --git a/src/nvim/testdir/test_langmap.vim b/src/nvim/testdir/test_langmap.vim new file mode 100644 index 0000000000..fc7c6734b1 --- /dev/null +++ b/src/nvim/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\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}%}\}^\00", 'tx') + call assert_equal('a}^de', getline(1)) + + quit! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 0f51f4af6e..b354c2eaeb 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -543,7 +543,7 @@ static int included_patches[] = { // 1153, // 1152 NA // 1151, - // 1150, + 1150, 1149, // 1148 NA // 1147, -- cgit From 24a329b53aa3be03ed79768cca04d63d6bb93891 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Sun, 22 May 2016 01:33:27 -0700 Subject: vim-patch:7.4.1151 Problem: Missing change to eval.c Solution: Also change feedkeys(). https://github.com/vim/vim/commit/5f8a14b9dea094b8bbab94cfc1e8da8e633fbc01 --- src/nvim/api/vim.c | 8 ++++++- src/nvim/ex_docmd.c | 5 +++- src/nvim/getchar.c | 4 ++-- src/nvim/testdir/test_langmap.vim | 48 +++++++++++++++++++-------------------- src/nvim/version.c | 2 +- 5 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 46d72b847d..43d58a539a 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -57,6 +57,7 @@ void vim_feedkeys(String keys, String mode, Boolean escape_csi) bool remap = true; bool insert = false; bool typed = false; + bool execute = false; if (keys.size == 0) { return; @@ -68,6 +69,7 @@ void vim_feedkeys(String keys, String mode, Boolean escape_csi) case 'm': remap = true; break; case 't': typed = true; break; case 'i': insert = true; break; + case 'x': execute = true; break; } } @@ -86,8 +88,12 @@ void vim_feedkeys(String keys, String mode, Boolean escape_csi) xfree(keys_esc); } - if (vgetc_busy) + if (vgetc_busy) { typebuf_was_filled = true; + } + if (execute) { + exec_normal(true); + } } /// Passes input keys to Neovim. Unlike `vim_feedkeys`, this will use a diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c0d5c37bc9..3f28435ec0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7863,7 +7863,10 @@ void exec_normal_cmd(char_u *cmd, int remap, bool silent) exec_normal(false); } -void exec_normal(int was_typed) +/// Execute normal_cmd() until there is no typeahead left. +/// +/// @param was_typed whether or not something was typed +void exec_normal(bool was_typed) { oparg_T oa; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 36fe393f18..ae1857f318 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1754,9 +1754,9 @@ static int vgetorpeek(int advance) || ((compl_cont_status & CONT_LOCAL) && (c1 == Ctrl_N || c1 == Ctrl_P))) ) { - if (c1 == K_SPECIAL) + if (c1 == K_SPECIAL) { nolmaplen = 2; - else { + } else { LANGMAP_ADJUST(c1, (State & (CMDLINE | INSERT)) == 0 && get_real_state() != SELECTMODE); nolmaplen = 0; diff --git a/src/nvim/testdir/test_langmap.vim b/src/nvim/testdir/test_langmap.vim index fc7c6734b1..066c3bf2bd 100644 --- a/src/nvim/testdir/test_langmap.vim +++ b/src/nvim/testdir/test_langmap.vim @@ -1,24 +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\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}%}\}^\00", 'tx') - call assert_equal('a}^de', getline(1)) - - quit! -endfunc +" 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\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}%}\}^\00", 'tx') + call assert_equal('a}^de', getline(1)) + + quit! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b354c2eaeb..99bf21466d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -542,7 +542,7 @@ static int included_patches[] = { // 1154 NA // 1153, // 1152 NA - // 1151, + 1151, 1150, 1149, // 1148 NA -- cgit